SQL delete condition

Fermé
Catcheur08 - 7 févr. 2011 à 14:34
sakoba2010 Messages postés 157 Date d'inscription lundi 7 février 2011 Statut Membre Dernière intervention 24 juillet 2013 - 7 févr. 2011 à 16:12
Bonjour,

je cherche à savoir si c'est possible de supprimer un champ d'une table que s'il n'existe pas dans une autre table.

Cela donnerai Delete champ1 from table1,table2 where table1.champ1=table2.champ2 si champ1<>champ2 (sinon aucune supression)

Merci

2 réponses

sakoba2010 Messages postés 157 Date d'inscription lundi 7 février 2011 Statut Membre Dernière intervention 24 juillet 2013 15
Modifié par sakoba2010 le 7/02/2011 à 16:15
Essais ça:

DELETE from tab1 where tab1.nomPersonne NOT IN(Select nom from tab2);

tu peux voir des examples ici:
http://sakoba.byethost13.com/2011/02/07/the-in-and-not-in-predicates/
1
remplace ton "si" par un "and"
0