所用的SELECT语句的列数不同

所用的SELECT语句的列数不同

本文介绍了所用的SELECT语句的列数不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我不知道每个表中有多少行,我尝试这样做:

For examples I don't know how many rows in each table are and I try to do like this:

SELECT * FROM members
UNION
SELECT * FROM inventory

如何在不添加NULL的情况下将第二个SELECT而不是*删除此错误?

What can I put to the second SELECT instead of * to remove this error without adding NULL's?

推荐答案

显式输入列名而不是*,并确保每次选择中同一列的列数和数据类型均匹配.

Put the columns names explicitly rather than *, and make sure the number of columns and data types match for the same column in each select.

更新:

我真的不认为您希望基于表名称对这些表进行UNION.它们似乎不包含相关数据.如果您发布架构并描述您要实现的目标,那么我们可能会提供更好的帮助.

I really don't think you want to be UNIONing those tables, based on the tables names. They don't seem to contain related data. If you post your schema and describe what you are trying to achieve it is likely we can provide better help.

这篇关于所用的SELECT语句的列数不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 07:44