[英]Matching Query from two tables
I have two tables as the following Table1 and Table2 我有两个表,如下表1和表2
Table1 as the following 表1如下
SiteClassification | Name1 | ID
---------------------------------------------
Golden AA 23
Platinum BB 24
Golden CC 25
Golden DD 26
Table2 as the following 表2如下
Motor | Name2 | ID
------------------------------------------
Perkins AB 23
Honda BA 24
Honda CA 25
Suzuki DF 26
What I can't do is create a Query that show a Table with all the records from both tables where the records have the same ID. 我不能做的是创建一个查询,该查询显示一个表,其中两个表的所有记录都具有相同的ID。
Result Needed 需要的结果
Motor | Name2 | ID | Name1 | SiteClassification
-------------------------------------------------------------------------
Perkins AA 23 AB Golden
Honda BB 24 BA Platinum
Honda CC 25 CA Golden
Suzuki DD 26 DF Golden
I tried to use a SELECT * FROM , LEFT JOIN but I'm always getting nothing!! 我试图使用SELECT * FROM,LEFT JOIN但我总是什么也没得到! can you please asist ..
你能帮忙吗..
regards, 问候,
尝试这个。
SELECT Motor,Name2,Table1.Id,Name1,SiteClassification FROM Table1 JOIN Table2 ON Table1.ID = Table2.ID
Try to use following query:- 尝试使用以下查询:
SELECT table2.motor, table1.name1 AS Name2, table1.id, table2.name2 AS Name1, table1.SiteClassification
FROM table1 INNER JOIN table2
ON table1.id = table2.id;
Hope this can help you. 希望这可以帮到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.