| Author |
Topic |
|
krish001
Yak Posting Veteran
61 Posts |
Posted - 2009-12-26 : 23:20:13
|
| Iam getting error subquery returned more than one value?? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
krish001
Yak Posting Veteran
61 Posts |
Posted - 2009-12-27 : 01:59:26
|
quote: Originally posted by krish001 Iam getting error subquery returned more than one value??
set @id=(select id from table where branch='b') select coloumn from table where id=@id when iam running this iam getting sub query error how pass id onfly?? |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-12-27 : 12:05:18
|
This is because in your table are more than one id where branch='b'.You variable @id can only take one value hence the error message.You can do this instead (only one example, I don't know your tables and so on):select column from table where id in (select id from table where branch='b') No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-28 : 00:48:28
|
| If both tables refer a same tableselect column from table where branch='b'MadhivananFailing to plan is Planning to fail |
 |
|
|
ms65g
Constraint Violating Yak Guru
497 Posts |
Posted - 2009-12-28 : 02:20:35
|
| For cross the errorexchange SET to SELECT (assignment select)select @id=id from table where branch='b' |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-12-28 : 04:10:24
|
quote: Originally posted by ms65g For cross the errorexchange SET to SELECT (assignment select)select @id=id from table where branch='b'
There is a problem with this. If there are more than one id returned, only the last id will be assigned to @idMadhivananFailing to plan is Planning to fail |
 |
|
|
ms65g
Constraint Violating Yak Guru
497 Posts |
Posted - 2009-12-28 : 09:28:12
|
quote: Originally posted by madhivanan
quote: Originally posted by ms65g For cross the errorexchange SET to SELECT (assignment select)select @id=id from table where branch='b'
There is a problem with this. If there are more than one id returned, only the last id will be assigned to @idMadhivananFailing to plan is Planning to fail
I know. It is just a way to crossing the error and nothing else. |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2009-12-28 : 11:37:26
|
| ON ERROR RESUME NEXT is NOT your friendhttp://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
|