Hello everyone, interested in how you can select records from two tables. There is a table1 in which data about users is stored and a table2 in which data that the user sends every day is stored. How can I choose records who did not send an answer today? I tried only this option:

SELECT U.* FROM user U WHERE NOT EXISTS( SELECT * FROM table P WHERE P.user_id=U.id AND data>='10.02.2019') 
  • In principle, the request is written correctly. True date in some strange format. If this field is of the date or datetime type, then the date is usually specified in the format YYYY-MM-DD. Also today's date can be obtained by the function curdate () - Mike
  • It seems to me nested will be executed for a long time with a large number of records. Why not use LEFT JOIN? combine these 2 tables, for the U.id field, add a distinct, and in where add an IS NULL condition and date comparison to get only those users for whom there was no match in the second table. If you also do the indexing to the required fields, then the sample will be performed instantly - Anatoly Shevelev
  • Can you please give an example, I can not figure out something - Prizrak771 February

0