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
 General SQL Server Forums
 New to SQL Server Programming
 where is the wrong in my query

Author  Topic 

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-06-22 : 01:12:55
Dear experts,
please let me know where is the mistake in my query

select distinct (select COLUMN003 from TABLE021 where COLUMN001 = t.COLUMN001)

+ '(' +(select COLUMN002 from TABLE021 where COLUMN001 = t.COLUMN001)+ ')' as tablename

(select COLUMN003 from CATABLE009 where COLUMN001 = t.COLUMN003) modulename from TABLE022 t order by tablename

Vinod
Even you learn 1%, Learn it with 100% confidence.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-22 : 01:22:15
1. subquery may return more than 1 row

why are you not using JOIN to do it ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-06-22 : 01:46:50
can you please tell me how can i use join here

Vinod
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-22 : 01:52:04
[code]SELECT DISTINCT
a.COLUMN003 + '(' + a.COLUMN002 + ')' AS tablename,
b.COLUMN003 AS modulename
FROM TABLE022 t
INNER JOIN TABLE021 a ON t.COLUMN001 = a.COLUMN001
INNER JOIN CATABLE009 b ON t.COLUMN003 = b.COLUMN001
ORDER BY tablename[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-22 : 01:52:07
Can you explain what you are trying to do?

Madhivanan

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

- Advertisement -