赞
踩
在三张没有主外键关联的表中取出自己想要的数据,并且分页。
水果表:
坚果表:
饮料表:
主要用UNION AL
UNION ALL 操作符用于合并两个或多个 SELECT 语句的结果集。
注意:UNION ALL内部的 SELECT 语句必须拥有相同数量的列。列也必须拥有相似的数据类型。同时,每条 SELECT 语句中的列的顺序必须相同 ; 另外,UNION ALL结果集中的列名总是等于 UNION ALL中第一个 SELECT 语句中的列名
// 详细sql语句
select * FROM(
(select fid,fname,price,type from fruits)
UNION ALL
(select nid,name,price,6 as type from nut)
UNION ALL
(select did,dname,price,7 as type from drinks)
) as fnd limit 0,10 -----fnd为表的别名
最终结果:
转载:https://blog.csdn.net/qq_38159467/article/details/85015559
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。