我需要有关MySQL / SQL基本问题的帮助。
我有两张桌子:
表1
house_id | house address | house_type_id |
------------------------------------------
1 | John str. | 33
2 | Peter str. | 41
3 | Louis str. | 33
4 | Harold str. | 17
表2
house_type_id | house_type_description
--------------------------------------
33 | Big
41 | Medium
17 | Small
我想得到以下结果:
house_id | house address | house_type_id |
------------------------------------------
1 | John str. | Big
2 | Peter str. | Medium
3 | Louis str. | Big
4 | Harold str. | Small
我尝试跟踪语句,但它没有提供所需的输出:
SELECT * FROM Table1, Table2 Where Table1.house_type_id = Table2.house_type_id
你能帮我解决一下这个问题吗?
答案 0 :(得分:0)
尝试:
SELECT house_id , house address, house_type_description
FROM Table1 inner join Table2
on Table1.house_type_id = Table2.house_type_id
答案 1 :(得分:0)
select a.house_id,a.house address,b.house_type_description from table1 a left join table2 b on a.house_type_id = b.house_type_id