Click here to Skip to main content
11,412,302 members (64,189 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server-2008
select Prod_Name from tbl_Product_Master where Prod_Name like 'm%'
 
select Prod_Name from tbl_Product_Master where Prod_Name not like 'm%'
Posted 31-Dec-12 23:53pm
Edited 1-Jan-13 0:00am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This is a fairly simple task.
Since the two Prod_Name values appear to be the same type, use the UNION[^] clause.

select Prod_Name from tbl_Product_Master where Prod_Name like 'm%' order by Prod_Name asc
UNION
select Prod_Name from tbl_Product_Master where Prod_Name not like 'm%'


Note that this will remove all duplicate values.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

There is a simpler way:
select Prod_Name from tbl_Product_Master where Prod_Name like 'm%' OR Prod_Name not like 'm%'
Which in this case is:
select Prod_Name from tbl_Product_Master
  Permalink  
Comments
Shambhoo kumar at 1-Jan-13 5:11am
   
Thanks......
:)
OriginalGriff at 1-Jan-13 5:13am
   
You're welcome!
Shambhoo kumar at 1-Jan-13 5:17am
   
sir actually i want to apply order by clause on first select statement not on second statement ,but it's not working ,...so u help me plz...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

i solve my self........
select Prod_Name from tbl_Product_Master where Prod_Name like 'm%'
union all
select Prod_Name from tbl_Product_Master where Prod_Name not like 'm%'
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 348
1 Sascha Lefévre 175
2 ProgramFOX 130
3 Maciej Los 110
4 Sergey Alexandrovich Kryukov 105
0 Sergey Alexandrovich Kryukov 8,980
1 OriginalGriff 7,263
2 Maciej Los 3,500
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web02 | 2.8.150414.5 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100