Search LIKE is correct in 2 following cases:
1. select Orders.ShipName from Orders where Orders.ShipName LIKE 'a%'
2. select Orders.ShipName from Orders where Orders.ShipName LIKE '_a%'
Note: (_) is blank.
But now I want to search LIKE use both 2 conditions above with records of condition 1 come first, then records of condition 2 come next. I try:
select Orders.ShipName from Orders where Orders.ShipName like 'a%' OR Orders.ShipName LIKE '%_a%'
But records mixed up each other between 2 conditions. Please give me a solution. Thanks a lot.
Loading
Venkatesan JayakanthamPosted Jun 11, 2010, 9:37 AM
select Orders.ShipName from Orders where Orders.ShipName LIKE 'a%'
union
select Orders.ShipName from Orders where Orders.ShipName LIKE '_a%'
Cheers,
Venkatesan Prabu .Jhttp://venkattechnicalblog.blogspot.com/
Amit ChoudharyPosted May 1, 2010, 5:39 AM
Try nested query... first fetch the result on basis of your first condition and then pass this result to outer query with second condition.. and your problem will be solved.
See if it works for you.
Please mark "Do you like this post" if it helps you.