Jump to content

[SOLVED] sql query help. Selectivly using the Match function


fou2enve

Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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'

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.