gpt4 book ai didi

mysql - 这个 UNION ALL mysql 查询有什么问题?

转载 作者:太空宇宙 更新时间:2023-11-03 10:26:01 25 4
gpt4 key购买 nike

SELECT 'Q' AS TYPE, 
q.question AS value,
q.date
FROM questions q
WHERE q.user_id =39
UNION ALL
SELECT 'A' AS TYPE,
q.question AS value,
a.date
FROM answers a,
questions q
WHERE a.question_id = q.id
AND WHERE a.user_id =39
ORDER BY `date` DESC

数据库设计:

  • 问题{id,user_id,question,date}
  • answers{id,question_id,user_id,answer,date}

错误:

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 'WHERE a . user_id = 39 ORDER BY date DESC

最佳答案

查询的下半部分有两个 WHERE 子句。您只需要从字面上删除最后一个词 WHERE。错误描述就是您所需要的。

关于mysql - 这个 UNION ALL mysql 查询有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5450838/

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