在哪里条件下如何使用像运算符? [英] How to use like operator in where condition ?
本文介绍了在哪里条件下如何使用像运算符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下查询可以正常运行...
Hi,
I have following query which works properly...
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%'
但是当我将T.store的位置条件更改为%0%"时
它给我所有具有0的商店匹配,这里我只想匹配0商店ID.
为此的任何方法...
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...
推荐答案
这将为您提供LIKE的概述
http://www.techonthenet.com/sql/like.php [
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 :)
然后您需要添加一个条件:
Then you need to add a condition:
SELECT * FROM myTable T WHERE T.stores LIKE '%0%' AND storeID=666
您只需要优化LIKE查询的结果即可!
You just need to refine the results of the LIKE query!
这篇关于在哪里条件下如何使用像运算符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文