gpt4 book ai didi

php - 使用 UNION 查询 MySQL,我在选择的列之一上遇到错误

转载 作者:行者123 更新时间:2023-11-29 05:24:58 28 4
gpt4 key购买 nike

<分区>

查询工作得很好,就像:

$query = '(SELECT contenttype, id, title, type, image, rating, date2, num_votes FROM videos)
UNION
(SELECT contenttype, id, title, type, image, rating, date2, num_votes FROM games)
UNION
(SELECT contenttype, id, title, type, image, rating, date2, num_votes FROM pics)
ORDER BY date2 DESC
LIMIT 10';
$r = mysql_query($query) or die(mysql_error());

但如果我尝试拉动柱子,开启,将无法正常工作。数据库中的所有表都使用名为 on 的列。我收到此错误:您的 SQL 语法有误;查看与您的 MySQL 服务器版本对应的手册,了解在“on, type, image, rating, date2, num_votes FROM videos”附近使用的正确语法 UNION (SELECT contentty' at line 1

我在查询中添加 on 的示例:

$query = '(SELECT contenttype, id, title, type, on, image, rating, date2, num_votes FROM videos)
UNION
(SELECT contenttype, id, title, type, on, image, rating, date2, num_votes FROM games)
UNION
(SELECT contenttype, id, title, type, on, image, rating, date2, num_votes FROM pics)
ORDER BY date2 DESC
LIMIT 10';
$r = mysql_query($query) or die(mysql_error());

对我来说没有意义。为什么会出现这种情况?

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