我有桌子人
create table Person (
id SERIAL not null,
...
);
person可以有0个或更多PreviousName
create table PreviousName (
id SERIAL not null,
person_id INTEGER not null,
value VARCHAR(120)
);
如何选择以前姓名“John”
中具有例如价值的所有人答案 0 :(得分:0)
select * from Person
where id in (select person_id from PREDCHOZI_JM_PR
where value = 'John')
答案 1 :(得分:0)
这就是我理解你的问题......
SELECT * FROM Person LEFT JOIN PREDCHOZI_JM_PR ON person.id=PREDCHOZI_JM_PR.person_id
WHERE value="John"
答案 2 :(得分:0)
您可以在PREDCHOZI_JM_PR中找到包含john值的不同person_id:
SELECT * FROM Person WHERE id IN (SELECT DISTINCT person_id FROM PREDCHOZI_JM_PR WHERE value LIKE '%John%')