Click here to Skip to main content
12,451,425 members (52,585 online)
Rate this:
 
Please Sign up or sign in to vote.
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 22:53pm
Updated 31-Dec-12 23:00pm
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 1-Jan-13 5:11am
   
Thanks......
:)
OriginalGriff 1-Jan-13 5:13am
   
You're welcome!
Shambhoo kumar 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160826.1 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2016
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