If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > [Match any Portion] - Possible in Mysql?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-10-05, 22:09
ricoche ricoche is offline
Registered User
 
Join Date: Mar 2005
Posts: 9
[Match any Portion] - Possible in Mysql?

Hello,

We have an mysql inventory database. We want to be able to put in 4984.600 and choose "match any portion" and it finds 4984600 which is in our database.

Does Mysql have a "match any portion" search function? In this case LIKE didn't work which we tried already.

Any ideas? or are we stuck with using MSSQL. We know this will work with MSSQL.

Thank you very much. This is a huge problem for us.

Jim
Reply With Quote
  #2 (permalink)  
Old 10-11-05, 10:11
marist89 marist89 is offline
Registered User
 
Join Date: Oct 2002
Location: greenwich.ct.us
Posts: 279
Is that a text field or a number field?
__________________
Jeff Hunter
http://marist89.*************
Reply With Quote
  #3 (permalink)  
Old 10-11-05, 21:18
popskie popskie is offline
Registered User
 
Join Date: Oct 2004
Location: In cousin's house
Posts: 303
try dis,
select * from tablename where cast(floatfield as char) like '60%'
Reply With Quote
  #4 (permalink)  
Old 10-12-05, 03:04
ricoche ricoche is offline
Registered User
 
Join Date: Mar 2005
Posts: 9
Hi there,

Hi there,

Here you can see an example of what I am talking about.

First, go to this website http://www.bell-electrical.com. On the left side there is an "Inventory Search" section. Enter Part no. 4984.600 ( You don't have to enter a manufacturer, or check any radio boxes. ).

The website will now redirect to another website and display your result. It will contain the part number 4984600 without the decimal. That particular website is using an ASP script with an MSSQL backend. This is why I say it works with MSSQL. Whether it is the ASP script or something else using sql, I am not exactly sure, but they are doing something to make this work.

I am basically looking to implement something like this using php and mysql, but am unsure if it's possible. I have noticed that most big php scripts including vbulletin for example don't have this function either.

Any ideas on how they might be achieving this would be great.

Anyway, hopefully this reply will help everyone understand what I am trying to accomplish.

Thanks agains
Reply With Quote
  #5 (permalink)  
Old 10-12-05, 04:01
popskie popskie is offline
Registered User
 
Join Date: Oct 2004
Location: In cousin's house
Posts: 303
Will u pls put a sample data ? And what is the fieldtype?
Reply With Quote
  #6 (permalink)  
Old 10-12-05, 04:45
felixg felixg is offline
Registered User
 
Join Date: Apr 2005
Location: Lier, Belgium
Posts: 122
Quote:
Originally Posted by ricoche
Here you can see an example of what I am talking about.

First, go to this website http://www.bell-electrical.com. On the left side there is an "Inventory Search" section. Enter Part no. 4984.600 ( You don't have to enter a manufacturer, or check any radio boxes. ).

The website will now redirect to another website and display your result. It will contain the part number 4984600 without the decimal. That particular website is using an ASP script with an MSSQL backend. This is why I say it works with MSSQL. Whether it is the ASP script or something else using sql, I am not exactly sure, but they are doing something to make this work.
Aren't you jumping to a conclusion here?
Perhaps they are just removing punctuation from your input because they also store part numbers without punctuation.
If you e.g. put in '4984A600', it will not work (not even when you check 'Match any portion')

--
felix
Reply With Quote
  #7 (permalink)  
Old 10-12-05, 05:16
ricoche ricoche is offline
Registered User
 
Join Date: Mar 2005
Posts: 9
Quote:
Aren't you jumping to a conclusion here?
Perhaps they are just removing punctuation from your input because they also store part numbers without punctuation.
If you e.g. put in '4984A600', it will not work (not even when you check 'Match any portion')
Hi Felix,

I think you are on to something. They probably are removing the punctuation. Would this be something I put in a word noise file? Or do you think they did this using their asp script?

Thanks for the very helpful tip.

Jim
Reply With Quote
  #8 (permalink)  
Old 10-12-05, 05:30
felixg felixg is offline
Registered User
 
Join Date: Apr 2005
Location: Lier, Belgium
Posts: 122
Quote:
Originally Posted by ricoche
They probably are removing the punctuation. Would this be something I put in a word noise file? Or do you think they did this using their asp script?
You can add an additional (unique) column in your parts table in which you store your part number with a predefined set of characters removed (e.g. '.,- ').
In MySQL you could do this with

Code:
ALTER TABLE parts ADD COLUMN cpartnr CHAR(20) NOT NULL DEFAULT '';
UPDATE parts SET cpartnr = REPLACE(REPLACE(REPLACE(REPLACE(partnr, '.', ''), ',', ''), '-', ''), ' ', '');
ALTER TABLE parts ADD UNIQUE (cpartnr);
Then make sure you remove the same characters from the user's input string before you do the SELECT.

--
felix
Reply With Quote
  #9 (permalink)  
Old 10-12-05, 08:00
ricoche ricoche is offline
Registered User
 
Join Date: Mar 2005
Posts: 9
Hi felix,

You are brilliant!

Your answers directed me exactly to my problem and the solution. Your SQL helped me to create exactly what I needed in the database. Plus I was able to find the modification needed for the php to strip the period or any other punctuation if needed. The combination of the two have solved all of my current issues.

Thanks so much for understanding my post and pointing me in the right direction.

- Jim
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On