Find sentences with two words adjacent to each other in Pg
问题 I need help crafting an advanced Postgres query. I am trying to find sentences with two words adjacent to each other, using Postgres directly, not some command language extension. My tables are: TABLE word (spelling text, wordid serial) TABLE sentence (sentenceid serial) TABLE item (sentenceid integer, position smallint, wordid integer) I have a simple query to find sentences with a single word: SELECT DISTINCT sentence.sentenceid FROM item,word,sentence WHERE word.spelling = 'word1' AND item