Searching Two Fields
Posted: Sun May 04, 2008 11:35 am
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?
Thanks...for taking a look
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)";