Searching Two Fields

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bluewaves
Forum Newbie
Posts: 7
Joined: Sat May 03, 2008 10:12 am

Searching Two Fields

Post by bluewaves »

I am tweaking my search box and need help with the last line of code.

Up until then, the code works.

What I want it to do is to search a field called Description and search
for the key word. The Name field has upper case characters and lower case
characters and I was told that I needed to convert whatever was typed in
the search box to upper case.

The description field is "longtext". Do I have to make the description field into FULLTEXT
to have it be searchable?

Did I write my UNION correctly?

Code: Select all

$upperKeyword = strtoupper($keyword);  
  $query = "(SELECT * FROM fourchecks WHERE upper(name) like '%$upperKeyword%' ORDER BY Name)
   UNION (SELECT * FROM checksunlimited WHERE upper(name) like '%$upperKeyword%' ORDER BY Name)
   UNION (SELECT * FROM fourchecks WHERE Description like'%keyword%' ORDER By Name)";
Thanks...for taking a look
Post Reply