或者这样 select * from table1 where locate(trim(字段1),'R13639201107')>0 或者 select * from table1 where INSTR('R13639201107',trim(字段1))>0
以上三个我试了都不行呀我程序里的代码是这样的:$query = "select hmd from tel_hmd where hmd like '%{$tel2}%'"; $tel2就相当于是R13639201107原来的语句是判断hmd是否包含13639201107,现在要反过来判断hmd是否包含于R13639201107中
我写的是SQL 语句 你换到程序里面 有些拼接的东西要换的。。 比如变量的拼接一楼写的改成这样试试看select * from table1 where 'R13639201107' like concat('%',字段1,'%')
select * from table1 where tel regexp '13639201107';
$query = "select hmd from tel_hmd where hmd regexp '$tel2'";
我用这个语句查询,table1里有两条tel记录,一条是13639201107,一条是r13639201107,我的意思是要用这个语句: select * from table1 where tel regexp 'r13639201107';要能把两条记录都能查询出来,可查出来的是和r13639201107完全匹配的这一条记录,另一条没查询出来,感觉还是和like 一样的效果哦。
select * from table1 where 'r13639201107' regexp tel
本人亲试 select * from `4-6` where instr('112',id)>0类似 这样的可行你在程序中 用 要改一下格试。
select *
from table1
where locate(trim(字段1),'R13639201107')>0
或者
select *
from table1
where INSTR('R13639201107',trim(字段1))>0
$tel2就相当于是R13639201107原来的语句是判断hmd是否包含13639201107,现在要反过来判断hmd是否包含于R13639201107中
比如变量的拼接一楼写的改成这样试试看select *
from table1
where 'R13639201107' like concat('%',字段1,'%')
select * from table1 where tel regexp '13639201107';
我用这个语句查询,table1里有两条tel记录,一条是13639201107,一条是r13639201107,我的意思是要用这个语句:
select * from table1 where tel regexp 'r13639201107';要能把两条记录都能查询出来,可查出来的是和r13639201107完全匹配的这一条记录,另一条没查询出来,感觉还是和like 一样的效果哦。
select * from `4-6` where instr('112',id)>0类似 这样的可行你在程序中 用 要改一下格试。