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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Sub query using IN clause

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-05-30 : 09:29:57
Aravind writes "Table EMP: EMPID, EMPNAME
Table JOB: JOBID, JOBNAME

Query:
select * from emp where empid in
(select empid from JOB where JOBID != 0)

Expected output: Parser error as empid field is not available in JOB table.

Actual output: All rows from EMP table are returned.

If you run the subquery alone, the following error is displayed:
Server: Msg 207, Level 16, State 3, Line 1
Invalid column name 'empid'.

HOW IS THIS POSSIBLE?"

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-05-30 : 09:36:51
I dont know understand..???

how is Job and Emp table linked with each other.. ??



If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-05-30 : 09:45:34
(select empid from JOB where JOBID != 0)

Sounds like there is NO "empid" column in your table called JOB??

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-30 : 10:18:41
As error says empid is not a column of JOB table. Check it again

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -