:"NOT"명령과 비슷한 postgres SQL 명령이 있습니까? 예를 들어
Apple is a and b
Banana is a and b
Orange is a
나는 그것이 단지 만하지 B 물건을 보여줍니다 명령을 작성하는 것을 시도하고있다.
:"NOT"명령과 비슷한 postgres SQL 명령이 있습니까? 예를 들어
Apple is a and b
Banana is a and b
Orange is a
나는 그것이 단지 만하지 B 물건을 보여줍니다 명령을 작성하는 것을 시도하고있다.
테이블 구조
Fruit | Attribute
Apple A
Apple B
Banana A
Banana B
Orange A
쿼리
select t1.* from tbl t1
where t1.attribute = 'A'
and not exists (select * from tbl t2
where t2.fruit=t1.fruit and t2.attribute <> 'A')
<> 그 명령은 무엇을 위해 사용됩니까? –
"does not equal" – RichardTheKiwi
, 그래서 이것이 표준 SQL-2003 : 무슨 뜻 이죠
WITH tbl (Fruit, Attribute)
AS
(
SELECT Fruit, Attribute
FROM (
VALUES ('Apple', 'A'),
('Apple', 'B'),
('Banana', 'A'),
('Banana', 'B'),
('Orange', 'A')
) AS tbl (Fruit, Attribute)
)
SELECT T1.Fruit, T1.Attribute
FROM tbl AS T1
WHERE T1.Attribute = 'A'
AND 1 = (
SELECT COUNT(*)
FROM tbl AS T2
WHERE T2.Fruit = T1.Fruit
);
외면 해? 아마도 당신은'LIKE' 연산자를 사용하려고합니다 : http://www.postgresql.org/docs/9.0/interactive/functions-matching.html –