gpt4 book ai didi

mysql - 每个派生表都必须有自己的别名

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

我有以下查询:

SELECT `snap`.`ID`, `user`.`username`, `vote`.`type` 
FROM (`snap`) JOIN `user` as u ON `u`.`ID` = `snap`.`user`
LEFT JOIN (select * from vote where user = "18") as vote ON `snap`.`ID` = `vote`.`snap`
JOIN (SELECT CEIL(MAX(ID)*RAND()) AS ID FROM snap)) AS x ON `snap`.`ID` => `x`.`ID`
WHERE `snap`.`active` = 0 LIMIT 1

在我添加最后一个 JOIN 之前它工作得很好。现在我收到错误:“每个派生表都必须有自己的别名”。我知道这是因为每个表都需要它的别名,我需要在某个地方放置“as S”或其他东西,但我无法在此查询中找到如何做到这一点。

最佳答案

好像你在 snap 之后有额外的右括号。它应该是 1 个而不是 2 个右括号。

SELECT `snap`.`ID`, `user`.`username`, `vote`.`type` 
FROM (`snap`) JOIN `user` as u ON `u`.`ID` = `snap`.`user`
LEFT JOIN (select * from vote where user = "18") as vote ON `snap`.`ID` = `vote`.`snap`
JOIN (SELECT CEIL(MAX(ID)*RAND()) AS ID FROM snap) AS x ON `snap`.`ID` = `x`.`ID`
WHERE `snap`.`active` = 0 LIMIT 1

关于mysql - 每个派生表都必须有自己的别名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8524703/

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