0
SELECT id, name::tsvector @@ 'substring1 & substring2'::tsquery
FROM table

I have this. The result of this query has 2 fields: id, ?column? The ?column? field value is true or false. how can I get only the true results?

4 Answers 4

1
SELECT * FROM (
  SELECT id, name::tsvector @@ 'substring1 & substring2'::tsquery
  FROM table
) AS search
WHERE column = 't'

You can also use WITH: http://www.postgresql.org/docs/9.1/static/queries-with.html

Sign up to request clarification or add additional context in comments.

Comments

0

use WHERE clause.... (if i understand your need correctly)

WHERE condition = true

2 Comments

The field ?coumn? is generated by the query, it is not contained in a table.
it doesn't matter - you can still use where. to make it simple you might use AS to give it a short name and use where on the short name.
0

Add a WHERE clausure to fill this values. Something like this.

SELECT id, name::tsvector @@ 'substring1 & substring2'::tsquery FROM table WHERE ?column? = 1 (or True)

1 Comment

The field ?coumn? is generated by the query, it is not contained in a table.
0

use alias to reference your column

SELECT id, name::tsvector @@ 'substring1 & substring2'::tsquery AS condition
FROM table
WHERE condition = true

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.