'stock_num' is not within the scope of the joined table expression??
- From: yawnmoth <terra1024@xxxxxxxxx>
- Date: Tue, 30 Oct 2007 16:04:06 -0000
I'm trying to perform a two-table SELECT where each table has a column
named 'stock_num'. One of the tables, however, isn't necessarily
going to have row's for a given stock_num (it might or might not). To
get around this, I do a LEFT JOIN. Or atleast I'm trying to do one.
Unfortunately, I'm getting an error that I don't understand:
Sybase: Server message: Adaptive Server cannot perform the requested
action because column 'stock_num' is not within the scope of the
joined table expression. Check your command for missing or incorrect
database objects, variable names, and/or input data. (severity 16,
procedure N/A) in %filename% on line %linenumber%
Like I said, all the tables have the 'stock_num' column. I even
reference it in my WHERE. So why is it not "within the scope of the
joined table expression" (whatever that even means)?
Here's the SQL:
SELECT s.*
FROM location_stock ls, stock s
LEFT JOIN current_quantity cq
ON cq.stock_num = ls.stock_num
AND cq.location = 'A'
WHERE ls.location = 'A'
AND s.stock_num = ls.stock_num
If I replace s.* with COUNT(1), it works. Here's something else that
works:
SELECT ls.*
FROM location_stock ls
LEFT JOIN current_quantity cq
ON cq.stock_num = ls.stock_num
AND cq.location = 'A'
WHERE ls.location = 'A'
So why doesn't the first query work?
.
- Follow-Ups:
- Prev by Date: Re: User lost the password how to change it?
- Next by Date: Re: dbcmd(proc,"PREPARE TRANSACTION"); fails with syntax error
- Previous by thread: updated the record being inserted using trigger
- Next by thread: Re: 'stock_num' is not within the scope of the joined table expression??
- Index(es):
Relevant Pages
|
|