How to determine which column "matched"

From: Date: Sat, 12 Apr 2008 03:25:13 +0000
Subject: How to determine which column "matched"
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-272914@lists.php.net to get a copy of this message
I'm trying to figure out a way that SQL can pass a flag to PHP to say which column "matched" during a query. Let's say for instance that I want to search for the word "apple" in both column "producer", and column "designation". I was hoping I could do something like this: Select producer, flag=1 from wine where producer like '%apple%' UNION Select designation, flag=2 from wine where designation like '%apple%' and then in each row that comes back, I could determine which column did that match by doing a PHP analysis of the "flag" value. However, this doesn't appear to be the right way to go about this (mySQL doesn't like these flag=1, flag=2 things. Can someone help steer me in the right direction?

« previous php.general (#272914) next »