SebastianOpperman
SebastianOpperman

Reputation: 7336

DELETE FROM multiple conditions

I have two conditions in a DELETE MySQL statement. But it does not delete the record.

$sql="DELETE * FROM sportevent.event_registrations WHERE event_registrations.id = '$id' AND event_registration.eventname = $event";

Is there something wrong with my query? It works if I use only one WHERE condition, but I need to use two.

Upvotes: 6

Views: 11719

Answers (2)

Wasim Karani
Wasim Karani

Reputation: 8886

Try this

$sql="DELETE FROM sportevent event_registrations WHERE event_registrations.id = '$id' AND event_registrations.eventname = $event";

Upvotes: 2

Jon Skeet
Jon Skeet

Reputation: 1503899

I suspect this:

event_registration.eventname = $event

should be

event_registrations.eventname = $event

After all, you've used the plural form in both the "from" clause and the other part of the "where".

Also note that only one of your parameters is quoted - it's not clear to me how you're providing the parameters, but surely you should be consistent.

Upvotes: 6

Related Questions