What's wrong with this query?

From: Mike Christensen <mike(at)kitchenpc(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: What's wrong with this query?
Date: 2010-09-17 11:48:42
Message-ID: AANLkTinPRj7ZT_09erDtjvEnxsJScF-8sgcKoKqQ3R6e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Here's the query:

SELECT R.RecipeId, R.Title, R.Description, R.ImageUrl, R.Rating,
R.PrepTime, R.CookTime, R.OwnerId, U.Alias, ts_rank_cd(R.TextSearch,
query) as Rank
FROM Recipes R, plainto_tsquery('veggie burgers') query
INNER JOIN Users U ON U.UserId = R.OwnerId
WHERE (R.TextSearch @@ query)
AND NOT EXISTS (select 1 from RecipeIngredients inner join
IngredientBlacklist using (IngredientId) where RecipeId = r.RecipeId
and IngredientBlacklist.UserId =
'affaa328-5b53-430e-991a-22674ede6faf' limit 1)
ORDER BY Rank DESC LIMIT 100;

Here's the error:

ERROR:  invalid reference to FROM-clause entry for table "r"
LINE 3: INNER JOIN Users U ON U.UserId = R.OwnerId
                                         ^
HINT:  There is an entry for table "r", but it cannot be referenced
from this part of the query.
********** Error **********
ERROR: invalid reference to FROM-clause entry for table "r"
SQL state: 42P01
Hint: There is an entry for table "r", but it cannot be referenced
from this part of the query.
Character: 239

This seems to happen when I add the fulltext functions.  Thanks!
Mike

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Clark 2010-09-17 13:00:02 Re: Transposing rows and columns
Previous Message Peter Roethlisberger 2010-09-17 08:44:09 Re: libssl issue ?