gpt4 book ai didi

php - MySQL "NOT IN"/"LEFT JOIN"给出错误

转载 作者:行者123 更新时间:2023-11-29 09:04:49 24 4
gpt4 key购买 nike

我想向 phpbb3 karma mod 写入额外的查询它检查用户在没有向其他 3 个人提供 karma 之前不能向同一个人提供 karma。但我的 SQL 语法收到错误...

我检查了thisthis我写的链接和查询如下所示

SELECT * 
FROM phpbb_karma AS out
WHERE out.poster_id = 134
AND out.poster_id
NOT IN
(SELECT k.karma_id, k.user_id, k.poster_id
FROM phpbb_karma AS k
WHERE user_id = 108
ORDER BY k.karma_id DESC LIMIT 3)

所以我的内心查询得到了他(poster_id)给予业力的最后3个人(user_id)。这个查询单独工作,但与我的外部查询一起它给我错误

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'out WHERE out.poster_id = 134 AND out.poster_id NOT IN (SELECT k.karma_id, k.u' at line 2

在我的外部查询中,我写道将接受业力的人是 134并且他不能出现在我的内部查询结果中。

该查询可能有什么问题?错误真的在第二行吗?

我用 LEFT JOIN 编写了相同的查询,但它给了我相同的语法错误

SELECT *
FROM phpbb_karma AS out
LEFT JOIN phpbb_karma AS in
ON in.poster_id = out.poster_id
WHERE in.poster_id = 134 AND in.poster_id IS NULL

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'out LEFT JOIN phpbb_karma AS in ON in.poster_id = out.poster_id WHERE in.poster_' at line 2

MySQL版本是MySQL client version: mysqlnd 5.0.7-dev - 091210 - $Revision: 304625 $但我不认为问题出在版本上,因为 LEFT JOIN 也不起作用

最佳答案

使用不同的别名,因为 out 是保留关键字:http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

关于php - MySQL "NOT IN"/"LEFT JOIN"给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7372302/

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