如何将多个表中的数据检索到colunm上 [英] How to retrive a data from multiple table into on colunm

查看:70
本文介绍了如何将多个表中的数据检索到colunm上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个4桌的学生,tpo,campany,admin'每个人都有一个列名'email',我想将表格中的所有电子邮件整理成一列,以便我可以验证电子邮件中的所有电子邮件列根据用户输入。





感谢和问候

vivek singh



我尝试了什么:



我谷歌很多,我没有找到任何正确的查询..

I have a 4 tables 'student,tpo,campany,admin' each one is having a column name 'email', i want to retive all emails present in tables into one column so that i can validate all emails present in email column according to user input.


thanks and regards
vivek singh

What I have tried:

I google a lot and i didnt find any proper query..

推荐答案

您是否尝试过联合查询



Have you tried a union query

select email from student where ...
union
select email from tpo where ...
union 
select email from company where ...
union 
select email from admin where ... 





有帮助吗? (显然你必须填写where语句,但这就是要点)



does that help ? (obviously you have to fill out the where statements, but thats the gist)


使用 UNION [ ^ ]

use UNION[^]
select email from table_01 union   select email from table_02 union   select email from table_03 union    select email from table_04



写一个存储过程用参数检查@email并检查上面结果中是否存在@email。


write an stored procedure to check with a parameter as @email and check whether the @email is present in the above result.


这篇关于如何将多个表中的数据检索到colunm上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆