您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

MySQL-从多个表中选择,可能没有联接?

MySQL-从多个表中选择,可能没有联接?

确实听起来像您想要@H_301_1@UNION两个表之间的一个。现在,您得到的是笛卡尔积,这就是为什么结果如此之大的原因:

@H_301_1@select *, 'painted' Source
from painteditems
where visible = 1
    and painteditemname = 'itemname1'
    and painteditemcolor = 'black'
union all
select *, 'special' Source
from specialitems
where visible = 1
    and specialitemname = 'itemname1'
    and specialitemcolor = 'black'

您需要将替换为@H_301_1@SELECT *您的列名。此外,两个查询中的列数和数据类型数必须匹配。

@H_301_1@UNION ALL将返回两个表中的所有行,如果您只想要@H_301_1@DISTINCT行,则将要使用@H_301_1@UNION

MySQL 2022/1/1 18:48:48 有291人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶