我正在尝试使用每列的不同SELECT语句在SQL中创建一个表。例如:
Column 1: SELECT name FROM Person WHERE name LIKE '%anna%'
COLUMN 2: SELECT cost FROM Property WHERE cost > 18000
然后根据公共属性加入这些列:
INNER_JOIN Property ON Property.id=Person.id
我该怎么做?
到目前为止,我尝试了以下方法,并想知道这是否正确。
select "Person"."name" as "name",
"Property"."cost" as cost
from "my_schema"."Person" "Person",
"my_schema"."Property" "Property"
where "Person"."name" LIKE '%anna%'
and "Property"."cost" > 18000
and "Person"."id"="Property"."id"
这两种方法有区别吗?真的很感激一些帮助
答案 0 :(得分:2)
我相信你正在寻找的东西:
SELECT
Person.name
, Property.cost
FROM Person
INNER JOIN Property ON Person.id = Property.id
WHERE Person.name LIKE "%anna%"
AND Property.cost > 18000