Click here to Skip to main content
15,895,256 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have following query which works properly...
SQL
select distinct als.sytem_no,
adm.firstName, + ' '+ adm.lastName as 'Name',
acs.*,als.* 
 from ac_storeKeys acs inner join ac_alarmSystems als 
 on acs.storeId=als.storeId
inner join ac_districts T 
on  acs.storeId='110'
inner join ac_districtManagers adm on adm.districts = T.district
--where acs.storeId='110'
where T.stores like '%110%'

But when i im changing where condition to where T.stores like '%0%'

It gives me all stores matches which having 0, here i only want to match 0 store id if it does.

Any apporach for this...
Posted
Updated 3-Oct-12 23:05pm
v2

this will give you overview of LIKE
http://www.techonthenet.com/sql/like.php[^]

but if you want the records which have 0 then use
where storeID=0

or

where storeID=0 and t.store like %0%

something like this


i think i deserve a five star answer :)
 
Share this answer
 
v4
Then you need to add a condition:
SQL
SELECT * FROM myTable T WHERE T.stores LIKE '%0%' AND storeID=666
You just need to refine the results of the LIKE query!
 
Share this answer
 

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