user2765552
user2765552

Reputation: 33

how can i delete records if two columns match mysql php

my problem is that I want to delete one record on my table "provicional" if "Id" and "Password" match... i have a simple code but just work for ID and I want to delete it if both match!

$sql = "DELETE FROM  `provicional` WHERE  `id` IN ('3','basico')";

many thanks for any help

Upvotes: 0

Views: 326

Answers (2)

Mosty Mostacho
Mosty Mostacho

Reputation: 43464

A not so popular way of doing this in MySQL would be:

DELETE FROM provicional WHERE (id, password) = (3, 'basico')

Note you can add more than just 2 elements in each list.

Tip: Do not use apostrophes ' around numeric fields.

Upvotes: 2

musical_coder
musical_coder

Reputation: 3896

$sql = "DELETE FROM  `provicional` WHERE  `id` IN ('3') AND `password` IN ('basico')";

Upvotes: 1

Related Questions