Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a table LIKES (ID1, ID2). Both id1 and id2 are non unique columns.

Database is SQLite

delete from LIKES where ID1 = 10   /// Wrong there more then one record with ID1=10
delete from LIKES where ID2 = 's ...'  /// Wrong there more then one record with ID1=155
delete from LIKES where ID1 = 10 and ID2='s ....' /// right query but i have to find out 
             values of id1 and id2 before to make run this query

delete from LIKES where id1=m and id2=t (select m, n  from table where ...some condition)

The last query does not work

share|improve this question
What exactly is that "some condition"? – CL. Feb 11 '13 at 10:38

Try using an EXISTS operator in your WHERE clause. I am not 100% of the exact syntax for sqlite but in SQL Server I would do something similar to the following:

DELETE from likes 
               FROM   table 
               WHERE  likes.id1 = table.m
                      AND likes.id2 = table.n
                      AND your other conditions )
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.