| Subject: | Re: SQL LIKE statement to text field fomr CF MX 6.1 |
|---|---|
| From: | GArlington <garlington@xxxxxxxxxxxxx> |
| Date: | Tue, 15 Apr 2008 02:16:25 -0700 (PDT) |
| Newsgroups: | macromedia.coldfusion.database_access |
On Apr 15, 1:37 am, "MichaelSJudd" <mikej...@xxxxxxxxxxxxxxxx> wrote: > Hi. > > Here's my scenario. I am running SQL Server 2000 SP4 on a Windows 2003 Server > running IIS 6. Using ColdFusion MX 6.1 Updater version. > > I am storing HTML page code (some complete, some just clips) in a text type > field. > > I need to check to see if someone has already saved that exact code already > before. So I do the following query: > > <cfquery name="checkforexisting" datasource="mydatasource"> > SELECT smallfieldtogetareturn > FROM MyTable > WHERE MyTextField LIKE '%#mystringoflongdata#%' > </cfquery> Why? If you are attempting to edit existing data use the primary key, if you are trying to save DB space(???) then DON'T -> you never know when the owner of the record you just found is going to change it, then your data (the second instance) will change too... > > Then to see if it posted: > > <cfif checkforexisting.RecordCount GT 0> > do the don't clip optional processing > </cfif> > > What is killing me is that it finds the match SOMETIMES. Just not ALL the > time. <snip> I suspect that the reason why "it finds the match SOMETIMES" is that your "mystringoflongdata" might have extra spaces (try trim(mystringoflongdata)), but still it is NOT a good idea to do it this way... |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: CF to MySQL stored proc question, crzymnmchl |
|---|---|
| Next by Date: | Re: Importing Access Database, GArlington |
| Previous by Thread: | SQL LIKE statement to text field fomr CF MX 6.1, MichaelSJudd |
| Next by Thread: | Re: SQL LIKE statement to text field fomr CF MX 6.1, Dan Bracuk |
| Indexes: | [Date] [Thread] [Top] [All Lists] |