此查询按预期返回5个结果
select * from [SalesLogix].[sysdba].[LEAD] where USERFIELD1 like '0'
但此查询不返回任何内容
select * from [SalesLogix].[sysdba].[LEAD] where USERFIELD1 like '1'
USERFIELD1是varchar 80字段
以下是数据库中的所有数据,你可以看到有两条记录,其中USERFIELD1 ='1'但它们之后似乎有一个换行符...可能是导致问题...无论如何都要抓住那两个记录
LEADID,CREATEUSER,CREATEDATE,MODIFYUSER,MODIFYDATE,ACCOUNTMANAGERID,ASSIGNDATE,BUSINESSDESCRIPTION,COMPANY,COMPANY_UC,CREDITRATING,DATAQUALITY,DESCRIPTION,DIVISION,DONOTSOLICIT,EMAIL,EMPLOYEES,FAX,FIRSTNAME,HOMEPHONE,IMPORTID,IMPORTSOURCE,INDUSTRY,INTERESTS,ISPRIMARY,LASTCALLDATE,LASTNAME,LASTNAME_UC,LEADSOURCEID,MIDDLENAME,MOBILE,NEXTCALLDATE,NOTES,PREFERRED_CONTACT,PREFIX,PRIORITY,QUALIFICATION_CATEGORYID,REVENUE,SECCODEID,SICCODE,STATUS,SUFFIX,TICKER,TITLE,TOLLFREE,TYPE,USERFIELD1,USERFIELD2,USERFIELD3,USERFIELD4,USERFIELD5,USERFIELD6,USERFIELD7,USERFIELD8,USERFIELD9,USERFIELD10,WEBADDRESS,WORKPHONE,LEAD_ADDRESSID,DONOTEMAIL,DONOTFAX,DONOTMAIL,DONOTPHONE
Q134915558 ,U6UJ9A00000S,2011-09-20 17:36:10.053,U6UJ9A00000S,2011-09-20 17:36:10.053,NULL,2011-09-20 17:36:10.053,NULL,Johndoe,JOHNDOE,NULL,NULL,NULL,NULL,0,test@gmail.com,NULL,NULL,Harry,NULL,NULL,NULL,NULL,Restaurant Pro Express demo download,T,NULL,Scott,SCOTT, ,NULL,NULL,NULL,this is from the site,NULL,NULL,NULL,NULL,NULL,SYST00000001,NULL,New,NULL,NULL,NULL,NULL,NULL,1
,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,4075559999,QQ134915558 ,NULL,NULL,NULL,NULL
Q39769667 ,U6UJ9A00000S,2011-09-20 17:46:18.103,U6UJ9A00000S,2011-09-20 17:46:18.103,NULL,2011-09-20 17:46:18.103,NULL,scaoo,SCAOO,NULL,NULL,NULL,NULL,0,harry333@harry.com,NULL,NULL,upper2,NULL,NULL,NULL,NULL,Aldelo for Restaurants demo download,T,NULL,Scott,SCOTT,L6UJ9A000004,NULL,NULL,NULL,this is a download,NULL,NULL,NULL,NULL,NULL,SYST00000001,NULL,New,NULL,NULL,NULL,NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,4074615519,QQ39769667 ,NULL,NULL,NULL,NULL
Q488888476 ,U6UJ9A00000S,2011-09-20 17:49:28.963,U6UJ9A00000S,2011-09-20 17:49:28.963,NULL,2011-09-20 17:49:28.963,NULL,Johndoe,JOHNDOE,NULL,NULL,NULL,NULL,0,markus@gmail.com,NULL,NULL,upper,NULL,NULL,NULL,sales,posnation.com online demo request,T,NULL,Scott,SCOTT,L6UJ9A000004,NULL,NULL,NULL,this is from upper,NULL,NULL,NULL,NULL,NULL,SYST00000001,NULL,New,NULL,NULL,NULL,NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,4074615519,QQ488888476 ,NULL,NULL,NULL,NULL
Q504845720 ,U6UJ9A00000S,2011-09-20 17:06:10.053,U6UJ9A00000S,2011-09-20 17:06:10.053,U6UJ9A00000G,2011-09-20 17:06:10.053,NULL,Rafner ext.,RAFNER EXT.,NULL,NULL,NULL,NULL,0,raf@raf.com,NULL,NULL,James,4075615519,NULL,NULL,sales,NULL,NULL,NULL,Rafner,RAFNER, ,NULL,NULL,NULL,Raf associates is asking a question,NULL,NULL,NULL,NULL,NULL,SYST00000001,NULL,New,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,QQ504845720 ,NULL,NULL,NULL,NULL
Q539171226 ,U6UJ9A00000S,2011-09-20 17:49:28.963,U6UJ9A00000S,2011-09-20 17:49:28.963,NULL,2011-09-20 17:49:28.963,NULL,scaoo,SCAOO,NULL,NULL,NULL,NULL,0,harry333@harry.com,NULL,NULL,upper3,NULL,NULL,NULL,NULL,Aldelo for Restaurants demo download,T,NULL,Scott,SCOTT,L6UJ9A000004,NULL,NULL,NULL,this is a download,NULL,NULL,NULL,NULL,NULL,SYST00000001,NULL,New,NULL,NULL,NULL,NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,4074615519,QQ539171226 ,NULL,NULL,NULL,NULL
Q547088411 ,U6UJ9A00000S,2011-09-20 17:46:18.103,U6UJ9A00000S,2011-09-20 17:46:18.103,NULL,2011-09-20 17:46:18.103,NULL,Johndoe,JOHNDOE,NULL,NULL,NULL,NULL,0,markus@gmail.com,NULL,NULL,upper,NULL,NULL,NULL,sales,posnation.com online demo request,T,NULL,Scott,SCOTT,L6UJ9A000004,NULL,NULL,NULL,this is from upper,NULL,NULL,NULL,NULL,NULL,SYST00000001,NULL,New,NULL,NULL,NULL,NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,4074615519,QQ547088411 ,NULL,NULL,NULL,NULL
Q913526837 ,U6UJ9A00000S,2011-09-20 17:36:10.053,U6UJ9A00000S,2011-09-20 17:36:10.053,NULL,2011-09-20 17:36:10.053,NULL,Johndoe,JOHNDOE,NULL,NULL,NULL,NULL,0,test@gmail.com,NULL,NULL,Parry,NULL,NULL,NULL,NULL,Restaurant Pro Express demo download,T,NULL,Scott,SCOTT, ,NULL,NULL,NULL,this is from the site agan,NULL,NULL,NULL,NULL,NULL,SYST00000001,NULL,New,NULL,NULL,NULL,NULL,NULL,1
,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,4075559999,QQ913526837 ,NULL,NULL,NULL,NULL
Q925684753 ,U6UJ9A00000S,2011-09-21 09:36:10.420,U6UJ9A00000S,2011-09-21 09:36:10.420,NULL,2011-09-21 09:36:10.420,NULL,POSfasion,POSFASION,NULL,NULL,NULL,NULL,0,sdfa@ss.com,NULL,NULL,Maria,NULL,NULL,NULL,NULL,Aldelo for Restaurants demo download,T,NULL,becker4,BECKER4,L6UJ9A000004,NULL,NULL,NULL,this is another lead from the live site,NULL,NULL,NULL,NULL,NULL,SYST00000001,NULL,New,NULL,NULL,NULL,NULL,NULL,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,7778889999,QQ925684753 ,NULL,NULL,NULL,NULL
答案 0 :(得分:4)
如果userField1
中的1之后有字符,请尝试使用通配符,如下所示。
select * from [SalesLogix].[sysdba].[LEAD] where USERFIELD1 like '1%'
你写的声明
select * from [SalesLogix].[sysdba].[LEAD] where USERFIELD1 like '1'
基本上等同于
select * from [SalesLogix].[sysdba].[LEAD] where USERFIELD1 = '1'
您可能想要阅读LIKE
clause
答案 1 :(得分:1)
使用
where USERFIELD1 = '1
'
您不需要LIKE
,因为您没有使用任何外卡。
答案 2 :(得分:1)
LIKE
错误。在其中放置通配符或模式,或使用=
运算符。答案 3 :(得分:1)
尝试使用通配符
包围的值即USERFIELD1 like '1%'
如果与换行符相关的话,应该排除你遇到的任何问题