SQl Query

What is the correct sql query to delete from table1 column 1 where table1 column = table2 column2.
Who is Participating?
Éric MoreauSenior .Net ConsultantCommented:
you can also do:

delete from table1
where column1 in (select column2 from table2)
Guy Hengel [angelIII / a3]Billing EngineerCommented:
delete means delete a row
you might however want only to clear a column value which would be an update

DELETE table1
FROM table1
JOIN table2
  ON table1.column = table2.column2

 --- or ---
UPDATE table1
  SET column1 = NULL
WHERE column IN  ( select column2 FROM table2 )
thenoneAuthor Commented:
so its that simple basically the join has to be called in order to make it work!!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.