mardi 26 juillet 2016

phpmysql delete data from two not related table in one query

i have to table tbl1 and tbl2 and there is no relation between them, i want to delete different data from both table using one query is that possible or should i do it in two separate query

i tried the following query

$del =" 
DELETE 
  FROM tbl1
    , tbl2 
 WHERE tbl1.delete_time IS NOT NULL
   AND tbl1.delete_time != '0000-00-00 00:00:00' 
   AND tbl2.delete_time IS NOT NULL 
   AND tbl2.delete_time != '0000-00-00 00:00:00'
";                   
$sql =mysql_query($del) or die(mysql_error());
$res = mysql_query($sql);

but i got the following error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE tbl1.delete_time IS NOT null AND tbl1.delete_time != '0000-0' at line 1

thanks in advance

Aucun commentaire:

Enregistrer un commentaire