SELECT Table From Select Other Table

编程入门 行业动态 更新时间:2024-10-11 17:25:19
本文介绍了SELECT Table From Select Other Table的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何从选择其他表中选择表格? 表1 ========== ID |姓名| ---------- 1 |亨利 2 | Dony ---------- 表2 ====== ===== ID |地址| ----------- 1 |伦敦 2 |得克萨斯州 ----------- i有选择ID table2来自Select table1,如下所示:

how to select table from select other table ? Table1 ========== ID| Name | ---------- 1 | Henry 2 | Dony ---------- Table2 =========== ID| Addres| ----------- 1 | London 2 | Texas ----------- i have select ID table2 From Select table1, like below :

SELECT ID From Table2 Where Select ID From Table1

推荐答案

由于表的关系未知,因此您的表示例和描述没有太大的作用。我只能猜测ID列,但我不确定。 如果你想加入2个表中关于匹配信息的信息,我会从内连接 [ ^ ]。 你也可以查看有关外部联接的信息,如果你想显示左表中的信息而不是正确的表,我会谷歌TSQL左外连接 PS我假设你在看SQL Server,如果我错了请告诉我,我会更新我的答案。 Your table examples and description don't give much to go on as the relationship of the tables is not known. I can only guess on the ID columns but I am unsure. If you are looking at joining the information in the 2 tables on matching information I would start with inner join[^]. you can also look up information on outer joins, I would Google on "TSQL left outer join" if you want to show information that is in the left table but not the right table P.S I have made an assumption that you are looking at SQL Server, If I am wrong please let know and I'll update my answer.

你可以使用 IN 子句。 从table2中选择ID为id IN(从table1中选择id,其中<< some条件>>) 相同的查询可以写成 JOIN 。你可以自己尝试一下。 You can use the IN clause. select id from table2 where id IN (select id from table1 where <<some condition>>) The same query can be written as a JOIN. You can try that out yourself.

更多推荐

SELECT Table From Select Other Table

本文发布于:2023-08-01 21:42:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1271985.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:SELECT   Table   Select

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!