select * from
(
select * from A
union all select * from B
union all select * from C
union all select * from D
) t
where t.a like '%11%';
上述代码实现的功能是查询四个表A、B、C、D中的相同字段a,将a中与字符11匹配的结果全部返回给用户,其实实现的就是一个基于多表的模糊查询。。
select * from
(
select * from A
union all select * from B
union all select * from C
union all select * from D
) t
where t.a like '%11%';