Take the 2-minute tour ×
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. It's 100% free, no registration required.

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

1 Answer 1

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 
WHERE  EXISTS (SELECT *
               FROM   table 
               WHERE  likes.id1 = table.m
                      AND likes.id2 = table.n
                      AND your other conditions )
share|improve this answer

Your Answer

 
discard

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.