Ask a Question related to Macromedia ColdFusion, Design and Development.
-
DDhillon #1
SQL like statement
Where am I doing wrong here?
select company, womens from tblwshow where company LIKE '%things%'
I know that there is a text "things" in some of the company names but it is
not giving any output. I have used this code b4 too but I dont know where I m
doing wrong this time.
Thank you
DDhillon Guest
-
If Statement???
guys i was wondering if anybody here could help me. I have a page done up with all dynamic text and attributes on it that come from a management... -
Use of FOR statement
I am reading through a book on Objects and References and I don't understand this statement: $sum += $_ for split //; I thought a FOR... -
AW: if-else-statement
--On Wednesday, September 03, 2003 11:56 PM +0200 "B. Fongo" <mygrps@fongo.de> wrote: Look at the docs for CGI.pm under pragmas, the -nosticky... -
if statement
I'm trying to write an if statement i have two field, Status and Attendance. "status" value can be active or inactive "Attendance" value is active... -
IIF statement
Assuming the data is being entered via a form, then use the AfterUpdate event of the control that is bound to the signature field. The code you need... -
Aegis Kleais #2
Re: SQL like statement
Can you do a select * and see if you get ANY records? Step by step troubleshooting. What do you mean by it's not giving any output? What does the query's RECORDCOUNT return?
Aegis Kleais Guest
-
DDhillon #3
Re: SQL like statement
Yes I have tried doing Select *. It is not showing any recordcount.
DDhillon Guest
-
paross1 #4
Re: SQL like statement
Could you possibly be dealing with a case sensitivity issue? Perhaps you can
use a (database dependent) function to guarantee that you are matching case,
such as....
WHERE LOWER(company) LIKE '%things%'
--or--
WHERE LCASE(company) LIKE '%things%'
..etc.
Phil
paross1 Guest
-
DDhillon #5
Re: SQL like statement
Let me elaborate my problem little more. Actually I m trying to fing the
specific word from the list of 50,000 companies. Lets say I want to find the
company that name contains "things". I m trying to use this statement Select *
from tblwshow where company like '%things%'. Do you think I m doing it right?
I hope this will explain more.
DDhillon Guest
-
basky #6
Re: SQL like statement
You are doing it right. But as paross1 said is the DB case sensitive. What DB
are you using? What is the datatype of the company field?
Did you try paross1's solution?
Also make sure that there are some companies that has the string you are using
in the like constraint.
basky Guest
-
BenDC #7
Re: SQL like statement
For this kind of text search, verity is a much better tool and a much FASTER tool than a SQL like statement.... You can index the entire DB and search through it in miliseconds....
BenDC Guest
-
DDhillon #8
Re: SQL like statement
I m using MS Access. The field is memo type. I m copying and pasting the string
in statememnt. I have also tried using MS Access query view to see results. I
dont see anything when I run it.
SELECT * from tblwshow where company like '%AIRTIGER%'
The company name is "ATE AIRTIGER EXPRESS CANADA INC"
I think the query above should show some result.
DDhillon Guest
-
basky #9
Re: SQL like statement
I don't think you can use like operation on memo field in access. I am pretty sure about it, but please double check it.
basky Guest
-
basky #10
Re: SQL like statement
May be you can use Verity to solve this issue, or change the field type to varchar or equivalent thing in access.
basky Guest
-
DDhillon #11
Re: SQL like statement
To make myself more clear. Let me put down the code here. I think it will help
in understand the problem better:
I m running a list loop that searches each item from the loop in the name of
companies. Once it finds that item, it updates another field by putting 1 in it.
<cfset
thetext='Health,fitness,medical,physical,mental,sp iritual,spa,rejuvenation,relat
ionship,knowledge,empowerment,dr,chiropractic,chir opractor,skin,massage,therapy,
therapeutic,women,woman,feel,good,fit,curve,body,p leasure,her,she,physio,psychol
ogy,psychological,book,bond,chapter,slim,acupunctu re,acupressure,tai,herb,herbal
,adult,power,sex,make,making,treatment,lather,bath ,dental,dentist,disorder,teach
ing,teach,eye,female,age,lady,ladies,aerobic,optic al,optician,publish,weight,ref
lex,reduce,control,sport,yoga'>
<CFLOOP From = "1" To = "#listLen(thetext)#" INDEX = "i">
<cfquery name="getdata" datasource="#mydsn.dsn#">
select id,company,womens from tblwshow where company like
'#listgetat(thetext,i)#'
</cfquery>
<cfoutput>
#listgetat(thetext,i)#
</cfoutput>
</cfloop>
<cfoutput query="getdata" maxrows="1000">
<cfquery name="updatedata" datasource="#mydsn.dsn#">
update tblwshow set womens='1' where id=#getdata.id#
</cfquery>
</cfoutput>
</cfloop>
DDhillon Guest
-
The ScareCrow #12
Re: SQL like statement
You can't use a like statement on a memo field in ms access. I think you can't even use a memo field in the where clause
Ken
The ScareCrow Guest
-
DDhillon #13
Re: SQL like statement
I have used like clause before in the memo foeld. Do you think I wrote the right code though?
DDhillon Guest
-
basky #14
Re: SQL like statement
Ok I think I found the problem.
Use * instead of % signs. That let me use like on memo fields also. I tried
this from the access and could get that to work. Try it from a cfm page and let
us see how ODBC driver handles it.
So your query should look like
<cfquery name="getdata" datasource="#mydsn.dsn#">
select id,company,womens from tblwshow where company like
'*#listgetat(thetext,i)#*'
</cfquery>
Let us know if this has worked for you.
basky Guest
-
The ScareCrow #15
Re: SQL like statement
I stand corrected, I was sure I read it somewhere, anyway
basky, in access itself you use "*" when using a odbc driver you use "%"
But I think I found the problem, reserved words
Also there is no need to use the listgetat function
<cfloop index="idx" list="#thetext#">
<cfquery name="getdata" datasource="#mydsn.dsn#">
select [id],[company],[womens] from tblwshow where [company] like '#idx#'
</cfquery>
<cfoutput>
#idx#
</cfoutput>
Give that a try
Ken
The ScareCrow Guest
-
DDhillon #16
Re: SQL like statement
Thank you for all your guys help but this time I dont know maybe its newer
version of CF things arent working for me. I tried putting '*' as a wild
character in the query while using query view in access. It works fine. When I
use the simple query written below in cf its not showing any result at all. It
looks very simple but I dont know why its not working.
<cfquery name="getdata" datasource="#apnadirectory.dsn#">
select id,company,womens from tblwshow where company like '*SPA*'
</cfquery>
<cfoutput query="getdata">
#company#<br><br>
</cfoutput>
DDhillon Guest
-
basky #17
Re: SQL like statement
Did you try ScareCrow's suggestion. try using [ ] with % (if it does not work try * also)
basky Guest
-
The ScareCrow #18
Re: SQL like statement
If it works in access, create your query in access, test, then copy the query and paste into your cfquery tag, then see if this works. Note you will have to change the "*" for "%"
Ken
The ScareCrow Guest
-
Unregistered #19Unregistered Guest



Reply With Quote


