多表联合查询,合适同一结构的表

分类:mysql

 选取合适条件的内容语法:

select * from `$old3` where oldyear='$uy' and oldmonth='$um' and oldday='$ud' UNION ALL select * from `$old1` where oldyear='$uy' and oldmonth='$um' and oldday='$ud' UNION ALL select * from `$old2`  where oldyear='$uy' and oldmonth='$um' and oldday='$ud'

选取出全部内容语法:

select * from `$old3` UNION ALL select * from `$old1` UNION ALL select * from `$old2` 

 

注释:默认地,UNION 操作符选取不同的值。如果允许重复的值,请使用 UNION ALL。

UNION 操作符用于合并两个或多个 SELECT 语句的结果集。

 

请注意,UNION 内部的 SELECT 语句必须拥有相同数量的列。列也必须拥有相似的数据类型。同时,每条 SELECT 语句中的列的顺序必须相同。

 

本文链接: 多表联合查询,合适同一结构的表
版权所有:布士收藏夹在网络收集,如有侵犯你的权利, 请联系QQ:641868752。

评论

发表评论

*

* (显示gravatar头像)

Ctrl+Enter快捷回复

© 2014 布士收藏夹 all rights reserved.