Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old March 23rd, 2004, 07:50 PM
myraleen myraleen is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Ottawa, Ontario, Canada
Posts: 123 myraleen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to myraleen Send a message via AIM to myraleen
Select text string

I have a database with an id column and a data column

I have a php enabled script that searches this binary data column (BLOB) for a string.

So let's say:

$string = "Fox jumped over fences";

This I know for certain would be found in 5 rows.

I have this:

php Code:
Original - php Code
  1.  
  2. SELECT * FROM data WHERE data = '$string';


It is not working, and I'm certain it is because of the spaces in the string?
Because it will work with = as LIKE and string as '%$string%' or when i split up the string and make it just the words.

Problem is, then it returns all the rows in the database with only Fox, and not the rest of the string.

Any help would be appreaciated.

thanks

Reply With Quote
  #2  
Old March 23rd, 2004, 08:50 PM
honcho's Avatar
honcho honcho is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Cape Cod
Posts: 1,347 honcho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 2 sec
Reputation Power: 3
RE: Select text string

You might want to look into using MySQL's full-text search. Take a look at this page.

Reply With Quote
  #3  
Old March 23rd, 2004, 08:54 PM
myraleen myraleen is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Ottawa, Ontario, Canada
Posts: 123 myraleen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to myraleen Send a message via AIM to myraleen
RE: Select text string

Oh please.


I've read and read for two hours.
I just want to know... can a binary blob field be searched with anything other then column LIKE "$string"?

i'm so fusterated.


Reply With Quote
  #4  
Old March 23rd, 2004, 09:18 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: Select text string

you must remember that when you are searching a field for a string using 'equal' (=), then the whole field would would need to match the string. If you need to find a string contained inside another string (a substring if you will), then you will need to use the LIKE statement with the wildcard characters

Reply With Quote
  #5  
Old March 23rd, 2004, 09:41 PM
myraleen myraleen is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Ottawa, Ontario, Canada
Posts: 123 myraleen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to myraleen Send a message via AIM to myraleen
RE: Select text string

Thanks.

That's just it though

I want it to get the whole string, spaces and all.

Which are stored in binary in a blob field (uploaded from a file).

But it will only find it when they are broken up or it uses LIKE instead of =.

Which is fine, but not always going to be a definite result.

And it's not up to me to alter the database for fulltext searching.

So I want it to be column = "$string";

But it's only excepting column LIKE "%$string%";

So I was trying to figure out if it had something to do with binary data altering what the spaces were.

Reply With Quote
  #6  
Old March 23rd, 2004, 09:45 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: Select text string

is the column exactly that string and nothing else?

Reply With Quote
  #7  
Old March 24th, 2004, 12:17 PM
myraleen myraleen is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Ottawa, Ontario, Canada
Posts: 123 myraleen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to myraleen Send a message via AIM to myraleen
RE: Select text string

No, the column will have a great deal more.

It could be an entire document consisting of pages and pages of text with only that string as one small sentance contained within (all converted to binary in the blob of course).

It could be just that string, but it's unlikely. 99% chance that it contains more.

Reply With Quote
  #8  
Old March 24th, 2004, 12:43 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: Select text string

In that case, the only thing that would work would be a LIKE Statement and wildcards surrounding the string

Reply With Quote
  #9  
Old March 24th, 2004, 12:57 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Select text string

Ok Thanks!!!

LIKE it will be then.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Select text string


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway