Question:

SQL Delete query...How do I delete multiple rows from 2 columns?

by Guest60346  |  earlier

0 LIKES UnLike

eg. delete employees with manager number 1 and 2?

is it delete from EMP

where man = '1' and '2'

??

thank you

 Tags:

   Report

3 ANSWERS


  1. It depends on what you mean - can one employee have both manager 1 and 2? If so, then that's correct.

    If not, then you should be using 'OR'.


  2. a better solution is

    delete from emp where man in (1,2)

    using this, you can continue the numbering if you like without so much typing.

    eg "delete from emp where man in (1,24,56,78,901)" would select the rows where the value of the man column is one of the values between the brackets.. If you're using non-numerical values, don't forget to encase each in single quotes.

  3. No.

    Its man = '1' OR man = '2'

    Otherwise man would have to be equal to both 1 and 2, which is impossible.

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.