易截截图软件、单文件、免安装、纯绿色、仅160KB

百分 sql 查询 通配符 问题

我们知道 * 在 sql里 是通配符

我要检索 字段里带 * 号 的字符串 怎么办?

也就是说不吧* 当通配符,把*当成一般字符处理


比如 字符串 asdf_*lkjlkj



*不是通配符吧
查询
select * from tb where colname like '%*%'

还有下划线

SQL code:


select * from @tb
where charindex('*',status)>0



SQL code:

--> 测试数据: @tb
declare @tb table (status varchar(10))
insert into @tb
select '1**00' union all
select 'g_d' union all
select '*' union all
select ''



select * from @tb
where charindex('*',status)>0 or charindex('_',status)>0

status
----------
1**00
g_d
*

(3 行受影响)




SQL code:
A. 在 WHERE 中使用 LIKE 和 ESCAPE 语法
下例假定 description 列存在于 finances 表内。若要搜索其中的 description 列包含精确字符 g_ 的行,请使用 ESCAPE 选项,因为 _ 是通配符。如果不指定 ESCAPE 选项,查询将搜索任何包含字母 g 后跟除 _ 字符外的任何单个字符的描述值。

SELECT *
from finances
WHERE description LIKE 'gs_' ESCAPE 'S'


SQL code



Code highlighting produced by Actipro C


相关问答:

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

救命啊!!JSP连接SQL2000问题!

各位大侠救命啊 !!
刚装了SQL2000 sp3
想用JSP连接数据库但是出现问题了
我用的是JDK6.0+tomcat5.0+SQL2000 SP3+JDBC sp3
它显示的是
javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver fo ......

mysql语句优化问题 大家给优化个SQL语句

SELECT a.tguildname ,SUM(a.ct) +  if (SUM(b.ct) IS NULL ,0,SUM(b.ct)) from (
SELECT  tg.tguildname,c.cid, (
cf.fbb + cf.fgjbb + cf.fjybb + cf.fqb + cf.fgjqb + cf.fjyqb + cf.fqib + cf. ......

sql 語句

表      TT
字段    A1    A2    A3
      1    B    2008/07/09
      2    C  & ......

sql达人入,求一句sql,或者给出相应的解决方案



表a

线路代码 线路名称  Main_ID 
cir11    cirA        1
cir21    cirB        1
cir13    ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号