Good day. In general, I have such a need: There is a table:
id, operator, stantion, data, errors, file
The bottom line is what - the operator (and there are several of them) adds a file, and you need to put it all into a table. Each file from a specific station is a column stantion, and the whole snag is that you need to put in the table UNIQUE stantion values FOR THE DAY. Ie if for some reason the operator has unloaded the report on the same station twice a day, we do not write this to the database for the second time. Tried to do as:
INSERT INTO import_file (`operator`,`stantion`,`data`,`errors`,`file`) VALUES ('$operator', '$stantion', '$data') WHERE ((SELECT COUNT(*) FROM import_file WHERE `data`='$data' AND `stantion`='$stantion' AND `operator`='$operator') = 0) Naturally, nothing good has been received except for the abuse of MySQL. Maybe I am doing something wrong, maybe I reinvent the wheel, and for this there is some kind of standardized solution?