Problem in sql query...

Posted by Muhsinathk under Sql Server on 6/29/2012 | Points: 10 | Views : 930 | Status : [Member] | Replies : 5
hi,
i have a table table1.i want to retrieve 2 rows in one pararameter
Eg-table1 colums are tableid,tabledescription.Table fields are (1,customer),(2,sale),(3,vehicle)

Declare @TableID
Set @TableID=(Select tabledescription from table1 where (tabledescription='customer' OR tabledescription='vehicle')
when i execute this query,i am gettng an error..




Responses

Posted by: Kirthiga on: 6/30/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

Try this below query for your required output.

Declare @TableID table(tabledescription varchar(10))

Insert @TableID
Select tabledescription from table1 where tabledescription='customer' OR tabledescription='vehicle'
select * from @TableID




Muhsinathk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jasminej on: 6/30/2012 [Member] Starter | Points: 25

Up
0
Down
Try this...

Normally, "IN" operator also behave as "OR"
Select Tableid from Table1 Where tabledescription In ('customer','vehicle')


Muhsinathk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muralidosscm on: 7/4/2012 [Member] Starter | Points: 25

Up
0
Down
Select tabledescription from table1 where (tabledescription='customer' OR tabledescription='vehicle')

Regards
Muralidoss M

Muhsinathk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Premalatha on: 7/4/2012 [Member] Starter | Points: 25

Up
0
Down
http://stackoverflow.com/questions/5262513/select-multiple-rows-into-one-variable-in-sql-query

This is Sure to helps you,

http://stackoverflow.com/questions/5262513/select-multiple-rows-into-one-variable-in-sql-query

Premalatha
Software Engineer

Muhsinathk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 7/4/2012 [Member] Starter | Points: 25

Up
0
Down
Select tabledescription from table1 where (tabledescription='customer' OR tabledescription='vehicle')


u can use more than one parameter like this

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Muhsinathk, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response