按姓名模糊查询,返回userid, userName,phone,email四个字段table1,table2,table3可能都有匹配的信息,但是table1,table2,table3,中的字段名称可能不是userid,userName,phone,email
例如 table1中的字段为 cusid,cusName,cusPhone,cusemail,当然表中不止四个字段
如何将查询结果一起返回呢?
存储过程怎么写呢
例如 table1中的字段为 cusid,cusName,cusPhone,cusemail,当然表中不止四个字段
如何将查询结果一起返回呢?
存储过程怎么写呢
from table1
where username like '王'
union all
select userid, userName,phone,email
from table2
where username like '王'
union all
select userid, userName,phone,email
from table3
where username like '王'
select userid , userName , phone , email from tb1 where ...
union all
select cast(col1 as userid的类型), ... from tb2 where ...
union all
select cast(col1 as userid的类型), ... from tb3 where ...