gpt4 book ai didi

mysql 2 选择之和

转载 作者:行者123 更新时间:2023-11-29 12:34:14 25 4
gpt4 key购买 nike

我有mysql问题:

此表存储有关已转换影片的信息。这是我的第一个sql:

SELECT COUNT(*) FROM uzytkownicy_filmy WHERE id_uzytkownika =1341143 AND id_albumu=0

该表存储已添加的影片信息并等待其队列转换,转换结果将传输到表uzytkownicy_filmy这是第二个:

SELECT COUNT(*) FROM uzytkownicy_filmy_convert WHERE id_uzytkownika =1341143 AND id_albumu=0

问题是:

我如何连接两个结果并输入我的 SQL 查询:

        UPDATE uzytkownicy_filmy_albumy
SET ile_filmow=(

// Here I want the sum of the queries that you see above

)
WHERE id="' . $this->oDb->getSecureForm($iAlbumId) . '" AND id_uzytkownika="' . $this->oDb->getSecureForm($iUserId) . '"');

最佳答案

对两个查询求和的查询如下:

SELECT a.count + b.count FROM
(SELECT COUNT(*) AS count FROM uzytkownicy_filmy WHERE id_uzytkownika =1341143 AND id_albumu=0) AS a,
(SELECT COUNT(*) AS count FROM uzytkownicy_filmy_convert WHERE id_uzytkownika =1341143 AND id_albumu=0) AS b;

因此您只需在您的最终查询中添加此代码片段即可:

UPDATE uzytkownicy_filmy_albumy
SET ile_filmow=(

SELECT a.count + b.count FROM
(SELECT COUNT(*) AS count FROM uzytkownicy_filmy WHERE id_uzytkownika =1341143 AND id_albumu=0) AS a,
(SELECT COUNT(*) AS count FROM uzytkownicy_filmy_convert WHERE id_uzytkownika =1341143 AND id_albumu=0) AS b;

)
WHERE id="' . $this->oDb->getSecureForm($iAlbumId) . '" AND id_uzytkownika="' . $this->oDb->getSecureForm($iUserId) . '"');

关于mysql 2 选择之和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27036460/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com