I am writing a flexible search mechanism for a customer\'s website. I am utilizing union clauses to query a number of different fields in the database in search of a string
How about replacing:
SELECT * FROM test_table WHERE phone = 'email@example.com'
with:
SELECT * FROM test_table WHERE phone = 'email@example.com' and phone <> 0
<> means different from.
This will work for you because you are using 0 in the phone column to mean there isn't a phone number (although it would be better style to use NULL for no phone number).