Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
CoffeeAddict
Yak Posting Veteran
94 Posts |
Posted - 2010-04-22 : 14:50:16
|
| God I hate SQL, what now. What quirky gotcha or special thing did I miss for this inner SQL statement not able to see outside?select * from order owhere city = 'Baltimore' and NOT EXISTS (Select * from Cash c where c.id = o.id)Error: Multi part identifier o.id could not be boundOk, an inner select cannot see outside itself due to table scope or whatever...which I think is just stupid but you know...I can't figure out then how to twist this around to make it work. How the hell can I get this to be "happy". |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2010-04-22 : 14:55:01
|
Your query works fine for me. Are you sure you are showing us the actual query? Are you using SQL Server or some other dbms?Here's my test:create table #order (id int, city varchar(50))create table #cash (id int)insert into #order values(1, 'San Diego')insert into #order values(2, 'Baltimore')insert into #cash values(1)select * from #order owhere city = 'Baltimore' and NOT EXISTS (Select * from #cash c where c.id = o.id)drop table #order, #cash Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog |
 |
|
|
CoffeeAddict
Yak Posting Veteran
94 Posts |
Posted - 2010-04-22 : 15:21:03
|
| How weird. I opened a new query window (because I was also getting an error saying orders table did not exist and I know for a fact it does) and it's working fine.Thanks anyway. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
CoffeeAddict
Yak Posting Veteran
94 Posts |
Posted - 2010-04-24 : 23:05:18
|
| No I checked that several times. It was the right database. For some reason I see this a lot. SQL Server shows squigglies under certain parts of my syntax like tables, field names, etc. when there in fact is no problem. It's like SQL Server has cashed some old compiled errors and still showing squigglies for stuff that is no longer a syntax problem (after you've fixed it..it still shows squigglies for some reason like something is cached in SQL Server Query Analyzer). |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|