I have a DB with postgresql and I wrote two simple queries
select page from title where word = 'france' and part = 'headline';
and
select page from title where word = 'france'
intersect
select page from title where part = 'headline';
I think they should return the same result but actually it’s different. Any suggestions?
The table structure is simply id, word, page, part.
EDIT:
I tried also
select distinct
but the query with intersect always returns some non relevant results.
This is a DB of a simple reverse table of some web news pages. So page, word and part are not unique. But no duplicated entries.
WHERE (a) AND (b)is a boolean condition applied to Every record. A record only gets included if it satisfies the whole condition. In other words, only records wherewordis ‘france’ ANDpartis ‘headline’ at the same time will be included.Is what you need more similar to using an
ORin your condition?Or are you having problems due to there being multiple records referencing the same page?
For example…
'aaa'will be returned by both your queries.'bbb'will be returned by only your second query.