fou2enve Posted December 11, 2007 Share Posted December 11, 2007 Okay heres the story, I'm developing this search application. Theres a couple issues i am running into; 1. I want to search for specific text within a table. - Figgured that out with full text and the Match function. 2. Nows heres where it gets goofy, i want the match funtion to only search rows that has $input_name (a posted value from user) in the field `name` So I think im looking for a sql query that will allow me to use match but selectively, Is this even possible?? Is there a better way to do this? thanks for the help! Quote Link to comment Share on other sites More sharing options...
paul2463 Posted December 11, 2007 Share Posted December 11, 2007 have a look <a href="http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html#operator_like> Here at the Manual </a> the Mysql you are looking for LIKE Quote Link to comment Share on other sites More sharing options...
fou2enve Posted December 11, 2007 Author Share Posted December 11, 2007 okay let me re-word this, to make things clearer. theres a couple columns, one is `area`, another `aspect` and another `attraction` as an example in literal terms: mql, find $input in the column `aspect` and $input2 in the column `attraction` but limit yourself to rows that have 'san fransisco' as your `area` i can deal with it if i can only search for only one of the $inputs but i need sql to do this Quote Link to comment Share on other sites More sharing options...
mbeals Posted December 11, 2007 Share Posted December 11, 2007 you mean like: Select * from `foo` where area = 'San Fransisco' AND (`aspect` like $input and `attraction` like $input2) The ( ) are optional, but if you decide to change that inner 'and' to an 'or', you will need them. Since sql has to search the database line by line to pull the subset of rows where area = San Fransisco, just query that row while you are there and see if you really need it. This way you search everything only once. If you absolutely need to search subsets, consider generating individual tables for each 'area' Quote Link to comment Share on other sites More sharing options...
fou2enve Posted December 11, 2007 Author Share Posted December 11, 2007 oh wow i didnt think it was that easy. thanks guys! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.