I ‘m wondering if it possible to insert records based on a specific date/time in one query without first selecting it.
For example:
I want to insert only when there is no record from 2 minutes ago.
How would this be achieved?
Thanks in advance
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use the following statement instead of
INSERT INTO table_name VALUES (1,'foobar'):The trick is: Find a select statement, that returns a row with the columns to insert, if and only if the row should be inserted – and finally put
INSERT INTO table_namein front of it. Note that the tableDUALis special table in MySQL and other DBMS.