[thelist] SQL gurus

Jay Blanchard jay.blanchard at niicommunications.com
Fri Mar 25 14:55:11 CST 2005


[snip]
SELECT date,mileage FROM m WHERE notes LIKE '%brakes'%'     ---->

2005-03-24	95534	changed brakes

Good so far. But now what I want to do is display the results of the
first query AND highlight any results that are found (not show only
the results but everything).

Is there a way in SQL to do this... like adding a field so the array
comes back as:

2005-03-24	95534	changed brakes    match
2005-03-24	235235	changed tires

Note the extra field "match" for only matches... this would make it
much easier in PHP to loop ... if field value == match then make bold,
or whatever.
[/snip]

Try this...
select dateField, mileage, notes, if(notes = '%brakes%', 'match', '') AS
matched from m 

the pseudo 'matched' column will reflect 'match'

You're not using a date column called 'date' are you? That would be a
keyword and could cause you some problems down the line.


More information about the thelist mailing list