查询通过phpmyadmin执行,但不通过php脚本执行

时间:2014-04-01 20:25:17

标签: php mysql sql database sql-delete

我下面有2个mysql查询,我尝试通过php执行它们但出现语法错误。当我通过phpmyadmin执行它时,它就像一个显示正确结果的魅力,你可以帮助我吗?

DELETE a FROM wp_posts AS a INNER JOIN ( SELECT post_content, MIN( id ) AS min_id FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY post_content HAVING COUNT( * ) > 1 ) AS b ON b.post_content = a.post_content AND b.min_id <> a.id AND a.post_type = 'post' AND a.post_status = 'publish';

DELETE FROM wp_posts

WHERE post_content NOT LIKE '%<img src=%'AND ID not in (select post_id as p from wp_postmeta where meta_key like '_wp_attached_file')

OR `post_title` like '%.png%'

OR post_date < DATE_SUB(NOW(), INTERVAL 15 day);

1 个答案:

答案 0 :(得分:0)

如果要在查询中使用多个语句,则需要使用mysqli_multi_queryMultiple Statements页面中有更多信息。

请注意&#34;不支持在预准备语句中使用多语句。&#34;因此,仅仅因为这个原因,如果使用客户端提供的参数(例如请求变量),最好避免使用上述函数并坚持为每个语句准备一个预备查询。