MySQL Forums
Forum List  »  Perl

SELECT from 2 columns
Posted by: Jim Farthing
Date: September 21, 2007 10:56AM

Hi all,
I have what I hope is a simple question....

I have a table with several columns, the 2 I am concerned with at the moment are Category and Keywords.

I need to search both of these columns for a word or short phrase that I get from a form.

For example, the search can be 'Antiques' or 'Antique Dealers'

I tried to use this
SELECT name, address, city, phone
FROM valley
WHERE keywords LIKE '%$search%'
OR category LIKE '%$search%'
ORDER BY name LIMIT %d,%d"

in several different ways but no joy.

When I use that snippet of code, I will get any matches from 'keywords' but nothing from category, even though I know there is a category with the var in it....

I have also tried

SELECT name,address,city,phone
FROM valley
WHERE CONCAT_WS(' ',keywords,category) LIKE '%$search%'
ORDER BY name LIMIT %d,%d

This gives me nothing for multiword searches....

Any ideas?

Thanks,
Jim



Edited 2 time(s). Last edit at 09/21/2007 01:01PM by Jim Farthing.

Options: ReplyQuote


Subject
Written By
Posted
SELECT from 2 columns
September 21, 2007 10:56AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.