Click here to Skip to main content
15,922,533 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a query

"select * from details where id=7 or id=3 or id=11 or id=9"

while executing this query i need a result set like this.
Id   Name<br />
<br />
7    Ammu<br />
3    Jithu<br />
11    yana<br />
9    Achu<br />
How is it possible.? Can anyone help me?
Posted
Updated 5-Jul-11 23:24pm
v3

i got the solution.. solution is
"select * from details where id=7 union all  select * from details where id=3 union all  select * from details where id=11 union all select * from details where id=9"
 
Share this answer
 
v4
Try this.
select * from details where id IN (7, 3, 1) order by id desc

or
select * from details where id=7 or id=3 or id=1 order by id desc
 
Share this answer
 
v2
Comments
Aswathi Narayan 6-Jul-11 5:21am    
thank u for ur reply . but how can i execute when the query is like this?
"select * from details where id=7 or id=3 or id=17"
[no name] 6-Jul-11 5:22am    
Good Call Toniyo. My 5 for you.
Toniyo Jackson 6-Jul-11 5:23am    
Thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900