gpt4 book ai didi

mysql - SQL 子查询问题

转载 作者:可可西里 更新时间:2023-11-01 08:04:22 25 4
gpt4 key购买 nike

无法在 where 上捕获子查询输出

有我的SQL代码

SELECT Txn.TrnID, Txn.Date, Txn.Amount,
(SELECT `MetaValue` FROM `meta` WHERE `Parent` = 'DB_Transaction' AND `MainID` = Txn.TrnID AND `MetaKey` = 'SalesID' AND `MetaValue` = '803') AS SubqueryResult
FROM transaction as Txn
WHERE SubqueryResult = '803'
LIMIT 10

我遇到了这个错误

Unknown column 'SubqueryResult' in 'where clause'

最佳答案

希望你可以尝试 Dr. Stitch。这是

SELECT Txn.TrnID, Txn.Date, Txn.Amount, m.MetaValue FROM transaction as Txn inner join meta as m    on m.Parent = 'DB_Transaction' and m.MainID = Txn.TrnID AND m.MetaKey = 'SalesID' AND m.MetaValue = '803' LIMIT 10

关于mysql - SQL 子查询问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36855512/

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