+ 2

Can one use a where statement in an insert into statement??

This questions leads to a bigger question: can you insert data with a condition for example when a certain data doesn't exist then add it but if it does don't add it?

19th Aug 2017, 10:36 PM
Haitham Alhad Hyder
Haitham Alhad Hyder - avatar
3 Respostas
+ 3
You actually can By using the insert into select sql syntax you get to achieve that. A really good resource on the topic can be found here; https://www.w3schools.com/sql/sql_insert_into_select.asp
20th Aug 2017, 5:19 AM
Haitham Alhad Hyder
Haitham Alhad Hyder - avatar
+ 4
I'd say no. Now in a trigger you can have conditions before the insert. Like if an add/update to table A meets the conditions then insert into table B. Google triggers in sql. They're the difference between a dead database and an alive and kicking database.
7th Oct 2017, 2:55 AM
Dark Angel
Dark Angel - avatar
+ 1
no we can't use it.. if we insert a data which is already exist then it will give us error without condition / where clause
20th Aug 2017, 6:11 AM
preeti