2

I would like to do something like

SELECT * FROM (
    SELECT ('reword#' || reword) || reword_faq as reword FROM me_review_entries re
) as re
WHERE re.reword = 'reword#2#SOME_FAQ'

I tried to do

SELECT ('reword#' || reword) || reword_faq as foo FROM me_review_entries re
WHERE foo = 'reword#2#SOME_FAQ'

But I get:

ERROR:  column "foo" does not exist
LINE 2: WHERE foo = 'reword#2#SOME_FAQ'

Is the first way of doing the only way ? Or could I improve that ?

1
  • You can use column aliases on ORDER BY statement's but not at WHERE because WHERE is executed before SELECT Commented Jul 6, 2011 at 9:44

1 Answer 1

6

I think it depends on your database, but the foo column does not exist except within the query, so you might have to do:

SELECT ('reword#' || reword) || reword_faq as foo FROM me_review_entries re
WHERE ('reword#' || reword) || reword_faq = 'reword#2#SOME_FAQ'
Sign up to request clarification or add additional context in comments.

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.