|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi all
I want a output like that I have one table device in which some fileds are there and values are present i want to sort the records by the name filed of the device but with one condition is that the name filed value ='Miscellaneous' should come in the last. The Query is (SELECT ID,NAME,VALUE,DESCRIPTION,SHOW_ORDER,CREATED_BY,MO DIFIED_BY,DATE_CREATED,DATE_MODIFIED FROM DEVICE WHERE NAME <>'Miscellaneous' ORDER BY NAME) UNION (SELECT ID,NAME,VALUE,DESCRIPTION,SHOW_ORDER,CREATED_BY,MO DIFIED_BY,DATE_CREATED,DATE_MODIFIED FROM DEVICE WHERE NAME='Miscellaneous'); It is running succesfully but it is showing the records as select * from device Can any one help in who to write that query and whats the problem in my query. |
|
#2
|
|||
|
|||
|
Ummm... look at those two WHEREs, everything else is the same. You're combining everything where A is the same as B, and where A is not the same as B.
A UNION doesn't just add the results from one query to another, it runs both queries at once. |
|
#3
|
|||
|
|||
|
Quote:
Can u write the Qurey for that condition but i am writing the same query in the other tables that is running fine and also gives the correct result i want the result as Name Value Description show_order Abtile 5 Abite 3 Baulti 2 baulti 5 Mausi 1 Mausi 2 Trico 2 Trico 5 Miscellaneous 3 Miscellaneous 2 |
|
#4
|
|||
|
|||
|
can any tell the query which stated above wothout use of union because i am using mysql 3.2 i am not sure where union is supported in mysql 3.2
|
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > I am not getting the result of query though it is running |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|