Hi, I need to search for matches of a string in two different fields of a 
database table (column1, column2) and need to know which on of the two matched. 
I can do this (ignoring duplicates) with the following code: 

SELECT column1, 1 FROM TABLE WHERE column1 LIKE "%PATTERN%"
UNION
SELECT column2, 2 FROM TABLE WHERE column2 LIKE "%PATTERN%" 

the 1 and 2 indicate which column matched and will be by a higher level of my 
program. But, for performance reasons, I would like to scan the table once (it 
can have many records.) The problem is that a query like this


SELECT column1, column2 from TABLE WHERE column1 LIKE "%PATTERN%" or column2 
LIKE "%PATTERN%"


won't tell me what column matched the LIKE.

Is there a way to achieve this? 

Thanks in advance, Hernan.


      
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to