简体   繁体   中英

SQL QUERY UPDATE CONDITION

I need to add one condition to this query :

UPDATE o36t_orders s 
SET s.bonifico = EXISTS (SELECT 1 
                         FROM mytable d 
                         WHERE d.Descrizione_operazione 
                         LIKE CONCAT('%', s.shipping_number,'%') )

The condition should be to do the update only if s.bonifico != 1

What you probably want is this:

UPDATE o36t_orders s 
SET s.bonifico = EXISTS (SELECT 1 
                         FROM mytable d 
                         WHERE d.Descrizione_operazione 
                         LIKE CONCAT('%', s.shipping_number,'%') )
WHERE s.bonifico != 1;

You can use this code for your problem:

//CONNECT DB - FETCH RESULT
$variable=$row['s.bonifico'];
if($variable!='1'){    
UPDATE o36t_orders s SET s.bonifico = EXISTS (SELECT 1 FROM mytable d WHERE d.Descrizione_operazione LIKE CONCAT('%', s.shipping_number,'%') )
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM