[thelist] MYSQL - select from column
Adrian Fischer
adrian at logo-logic.com
Fri Dec 14 18:03:14 CST 2001
Hi Everyone,
I have a table that has numerous columns. One of which is called
"docCategories". People can enter up to 4 categories into the column.
Below is an extract from the column.
<snip>
Automotive:Exhaust||Automotive:Mechanical||Automotive:Tyres/Wheels||Automitv
e:Wrecking
</snip>
It is delimited by the double ||. I need people to be able to search by a
number of criteria, on of which is "Category".
Here is the SELECT statement that I use presently:
<snip>
$db_query = "SELECT
docId,docCat,docBusName,docStreet,docBusPhone,docDesc1,State,docRegion,docSu
burb,docHits FROM tblDockets WHERE docAccountEnd >= " . int($current_time) .
" AND docCat= '" . sqlEncode($form{'CATEGORY'}) . "' AND State = '" .
sqlEncode($form{'STATE'}) . "' ";
$db_query .= " AND docClosed <= 2 AND docPending=0 ORDER BY docSuburb LIMIT
$startrow, $limit ";
</snip>
How do I change the statement so that I can get the category that matches
the user input from the possible 4 categories that may be in column
(sperated by ||)?
Is it possible (I hope so)?
Thanks (yet again)
Regards
Adrian Fischer
More information about the thelist
mailing list