Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a table name data:
which have two columns name and work:
1 name: arun,kapil,rahul,monu;
2 work:teacher,student,teacher,student;

i want a query that show result like this:
name     work
arun     teacher
rahul    teacher
kapil    student
monu     student

i use that query:
SQL
select * from data where work=teacher UNION select * from data where work=student


but it not work according to me, so plz help me
Posted
Updated 4-Dec-12 17:26pm
v3

I think simple
SQL
select * from
data where work in ('teacher','student')


should do the job unless I have misunderstood the question or you have not presented the question.
 
Share this answer
 
Comments
Arun kumar Gauttam 4-Dec-12 7:21am    
thanks for answering but your query return all rows again, but i want that query return all record of "teacher" first and then it return all record of "student" ,
MT_ 4-Dec-12 7:22am    
apply order by work.
Arun kumar Gauttam 4-Dec-12 7:30am    
ok thanks it work fine
use this one

SQL
select * from data where work like 'teacher' 
UNION 
select * from data where work like 'student'
 
Share this answer
 
v2

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