Delete multiple rows

I want to delete all records in table participant_vote where the id matches the id of another table row.

Can this be done in one query?

This is the query I have now which returns the error that my subselect contains multiple rows

DELETE FROM participant_vote WHERE id = (SELECT id FROM vote WHERE facebookid = :facebookid)

Answers


DELETE FROM participant_vote WHERE id IN (SELECT id FROM vote WHERE facebookid = :facebookid)

IN being the trick. My feeling is that searching for the message would also have provided an answer.


Yes. Use the IN operator instead of the = operator.

DELETE FROM participant_vote
WHERE id IN (
    SELECT id
    FROM vote
    WHERE facebookid = :facebookid
)

Need Your Help

How to display xml data that is stored as Global data in grouped table view

iphone uitableview iphone-sdk-3.0 ios4

I am using XML Parser to parse a xml file and store as Global data. I am fetching that data and displaying it as a table. I am using this sample to include search functionality.

Layout inside Layout

java swing layout jpanel awt

I have a JPanel with a vertical BoxLayout, for one element i want to be able to use another BoxLayout which places elements horisontally.