[英]join two select statements side by side Sql
I have two select query statements. 我有两个选择查询语句。 I dont know to create table here.
我不知道在这里创建表。
Below are two tables. 下面是两个表。 Id is same, but Fname and Lname is different.
Id相同,但Fname和Lname不同。
Table1 have two columns 表1有两列
id Fname
1 Ahila
Table2 have two columns 表2有两列
id Lname
1 Kavitha
Output table should be single row with id and Fname and Lname : 1 and Ahila and Kavitha respectively 输出表应为id为Fname和Lname为1的单行,分别为Ahila和Kavitha
Please help me on this. 请帮我。
you need to use a join to join the two tables together, something like: 您需要使用联接将两个表联接在一起,例如:
select t1.id, t1.Fname, t2.Lname
from Table1 t1
inner join Table2 t2 on t1.id = t2.id
Use JOIN statement 使用JOIN语句
SELECT T1.id id , T1.Fname Fname, T2.Lname Lname
FROM table1 T1
JOIN table2 T2 ON T1.id = T2.id
select Fname from Table1 join Table2 on Table1.id = Table2.id where id = 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.