从mysql服务器中的3个表中获取数据 [英] Fetch data from 3 tables in mysql server

查看:93
本文介绍了从mysql服务器中的3个表中获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据库,用户,他们的组织和子办公室中有3个表。我必须获取所有orgId = 1且在伊斯兰堡市设有办事处的用户的所有电子邮件。



I have 3 tables in my db, Users, their organization and suboffices. i have to fetch all email of all users who have orgId = 1 and have office in islamabad city.

SELECT Email From Users Where OrgID = (SELECT  OrgID from  Organization where Name = 'ABC')  & (SELECT OrgID From SubOffice Where Name = 'xyz')



i必须得到从表中匹配orgId并返回主查询。


i have to get the matching orgId from both table and return to main query.

推荐答案

查看本教程页面。 SQL联接 [ ^ ]



它应该为您提供入门的基本信息。
Have a look at this tutorial page. SQL Joins[^]

It should give you the basic info for getting started.

< br>

开始关于 SQL JOIN





http://www.dotnet-tricks.com/Tutorial/sqlserver/ W1aI140312-Different-Types-of-SQL-Joins.html [ ^ ]


这篇关于从mysql服务器中的3个表中获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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