简体   繁体   English

PHP MySQL查询更新多个表

[英]php mysql query updating multiple tables

I have the following mysql query which I am running with php like so. 我有下面的mysql查询,我正在像这样用php运行。 Notice that the update query is updating multiple tables at the same time. 请注意,更新查询将同时更新多个表。

$sql1 = <<<TEST1
UPDATE catalog_topics a
LEFT JOIN catalog_files_join b ON a.catalogID = b.foreignKey
LEFT JOIN catalog_files_join c ON c.foreignKey = b.catalogFileID
LEFT JOIN catalog_files d ON d.catalogFileID = b.catalogFileID
LEFT JOIN catalog_lu_topics e ON a.topicID = e.topicID
SET d.catalogFileID = 'test1',
    b.catalogFileID = 'test1',
    c.foreignKey = 'test1'
WHERE b.fileTypeID = 'gvl401'
AND c.fileTypeID = 'gvl25'
AND e.parentID = 'top305'
AND a.sortorder =1
AND e.topicID = 'top312';
TEST1;
echo $sql1;
$returnVal = mysql_query($sql1);

I am seeing weird results if I run this query from php compared to when I run it directly in mysql. 与直接在mysql中运行相比,如果我从php运行此查询,我会看到奇怪的结果。 So I am wondering if there is some other way in php to handle queries that update multiple tables at same time? 因此,我想知道php中是否还有其他方法可以处理同时更新多个表的查询?

Eventhough, the above query runs fine (because $returnVal is 1) ...I dont see all the records updated in the DB. 尽管如此,以上查询运行良好(因为$ returnVal为1)...我看不到数据库中所有更新的记录。

Is there a way in php to get back the number of records that got updated? php中是否有办法取回已更新的记录数?

mysql_affected_rows()将返回已更新的记录数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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