gpt4 book ai didi

mysql - UNION 具有不同列数的多选择语句

转载 作者:行者123 更新时间:2023-11-29 08:25:59 27 4
gpt4 key购买 nike

如何合并这些每个表具有不同列数的选择语句?

(SELECT title, description, full_description, keywords, option1, option2, option3, option4, option5, option6, option7, option8 FROM articles WHERE title LIKE ? OR description LIKE ? OR full_description LIKE ? OR keywords LIKE ? OR option1 LIKE ? OR option2 LIKE ? OR option3 LIKE ? OR option4 LIKE ? OR option5 LIKE ? OR option6 LIKE ? OR option7 LIKE ? OR option8 LIKE ?) 
UNION ALL
(SELECT title, description, full_description, keywords, option1, option2, option3, option4, option5, option6, option7, option8 FROM news WHERE title LIKE ? OR description LIKE ? OR full_description LIKE ? OR keywords LIKE ? OR option1 LIKE ? OR option2 LIKE ? OR option3 LIKE ? OR option4 LIKE ? OR option5 LIKE ? OR option6 LIKE ? OR option7 LIKE ? OR option8 LIKE ?)
UNION ALL
(SELECT title, description, full_description, keywords, option1, option2, option3, option4, option5, option6, option7, option8 FROM products WHERE title LIKE ? OR description LIKE ? OR full_description LIKE ? OR keywords LIKE ? OR option1 LIKE ? OR option2 LIKE ? OR option3 LIKE ? OR option4 LIKE ? OR option5 LIKE ? OR option6 LIKE ? OR option7 LIKE ? OR option8 LIKE ?)
UNION ALL
(SELECT title, description, option1, option2, option3, option4, option5, option6, option7, option8 FROM gallery_images WHERE title LIKE ? OR description LIKE ? OR option1 LIKE ? OR option2 LIKE ? OR option3 LIKE ? OR option4 LIKE ? OR option5 LIKE ? OR option6 LIKE ? OR option7 LIKE ? OR option8 LIKE ?)
UNION ALL
(SELECT title, description, option1, option2, option3, option4, option5, option6, option7, option8 FROM pages WHERE title LIKE ? OR description LIKE ? OR option1 LIKE ? OR option2 LIKE ? OR option3 LIKE ? OR option4 LIKE ? OR option5 LIKE ? OR option6 LIKE ? OR option7 LIKE ? OR option8 LIKE ?)

我收到此错误:

The used SELECT statements have a different number of columns

最佳答案

简单地说:你不能 - 你必须向那些少于最大列数的子查询添加一些空白列(例如NULL as Blank1)

关于mysql - UNION 具有不同列数的多选择语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17903790/

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