UNION关键字报错:ERROR 1222 (21000): The used SELECT statements have a different number of columns
2017-02-12 17:36
696 查看
今天进行总结时,发现这个错误,后来,发现这是由于union 造成。
![](https://img-blog.csdn.net/20170212173141542?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2luYXRfMjg5Nzg2ODk=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
在使用union时,有以下规则。
1.必须由两条或者两条以上的select语句组成,语句之间用关键字union分隔
2.每个查询中必须包含相同的列,表达式或聚集函数(顺序可以不同)
3.列数据类型必须兼容,类型不必完全相同,但必须是DBMS可以隐含地转换的类型。
其中上面的错误就是犯了第二条的规则。图中给出了标记。
在使用union时,有以下规则。
1.必须由两条或者两条以上的select语句组成,语句之间用关键字union分隔
2.每个查询中必须包含相同的列,表达式或聚集函数(顺序可以不同)
3.列数据类型必须兼容,类型不必完全相同,但必须是DBMS可以隐含地转换的类型。
其中上面的错误就是犯了第二条的规则。图中给出了标记。
相关文章推荐
- ERROR 1222 (21000): The used SELECT statements have a different number of columns
- ERROR 1222 (21000): The used SELECT statements have a different number of columns
- ERROR 1222 (21000): The used SELECT statements have a different number of columns
- [Err] 1222 - The used SELECT statements have a different number of columns
- mysql The used SELECT statements have a different number of columns
- The used SELECT statements have a different number of columns
- sql语句遇到错误: The used SELECT statements have a different number of columns :
- sql异常-The used SELECT statements have a different number of columns
- The used SELECT statements have a different number of columns 错误解决
- Nhibernate: Foreign key must have same number of columns as the referenced primary key
- python中关于Np.hstack()错误的ValueError: all the input arrays must have same number of dimensions
- Reduce the Number of SQL Statements
- What are the different kinds of parsers used in XML?
- error -27257: Pending web_reg_save_param/reg_find/create_html_param[_ex] request(s) detected and reset at the end of iteration number 1
- mysql报错"ERROR 1206 (HY000): The total number of locks exceeds the lock table size"的解决方法
- Which of the following expression(s) will NOT cause an error when used to replace the ***** in the C
- Set Log Level Available log levels Messages in log files can have different log levels. Some of the
- ERROR 1206 (HY000): The total number of locks exceeds the lock table size
- Error Number : 1547 Error Message: Column count of mysql.proc is wrong. Expected 20, found 16. The
- Kettle解析JSON错误,We MUST have the same number of values for all paths,We can not find and data with path [$.