jeudi 28 mai 2015

USING IF with UPDATE MYSQL

Im trying to do an update with a IF function

IF(SELECT 'FUNCION' FROM tickets 
  WHERE (FUNCION = COR) AND (tickets.CLIENTE=clientes.CLIENTE)) 
THEN UPDATE `clientes` SET `ESTADO` = 'I';

I tried this but it seems I have a syntax error.

How can I get this to work?

EDIT: I want to update 'ESTADO' to 'I' if 'FUNCION', from another table, is 'COR' and the fields 'CLIENTE' match each other.

Aucun commentaire:

Enregistrer un commentaire