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

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

WBOY
WBOYOriginal
2016-06-06 09:44:251456browse

联合查询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正常查询吗?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn