您好,欢迎来到知高教育。
搜索
您的当前位置:首页联合查询-mysql结构不同多表查询,请教语句

联合查询-mysql结构不同多表查询,请教语句

来源:知高教育


联合查询mysql多表查询

我原来有几个结构相同的3个表 tab1、tab2、tab3

这3个表都有字段

col1、col2、col3

原来使用语句

(select * from tab1 where col1='$wd' or col2 LIKE '$wd%')
union all
(select * from tab1 where col1='$wd' or col2 LIKE '$wd%')
union all
(select * from tab1 where col1='$wd' or col2 LIKE '$wd%') LIMIT 0,20";

查询的

现在新加了个表 tab4 字段多了个col4

即:col1、col2、col3、col4

再用上面的语句 多加个个
(select * from tab4 where col1='$wd' or col2 LIKE '$wd%')
union all
后 查询提示

Invalid query: The used SELECT statements have a different number of columns

请问有什么语句可以带新加的tab4正常查询吗?

Copyright © 2019- zgia.cn 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务