php - MySQL check if rows exists and delete it in the same query -
i following in 1 query, wandering if possible:
$rowsq = $mysql->query("select * `table` (a='a' , b='b')"); if($rowsq->num_rows){ $mysql->query("delete `table` (a='a' , b='b')"); }
i have seen similar thing exists query different table so:
$mysql->query("delete `table` exists (select * `table2` table.id = table2.id)");
is possible on same table though , if have rewrite same conditions or there shorter way?
you can use delete
, in case row doesn't exists specified values, query return out doing thing. can avoid select
delete table ='a' , b='b'
Comments
Post a Comment