In MySQL
with MyISAM
, you can create a FULLTEXT
index
CREATE FULLTEXT INDEX fx_customeraddresses_123 ON FIN_LIVE.CUSTOMER_ADDRESSES (SYS_ADDRESS_1, SYS_ADDRESS_2, SYS_ADDRESS_3)
and issue this query:
SELECT *
FROM FIN_LIVE.CUSTOMER_ADDRESSES
WHERE MATCH(SYS_ADDRESS_1, SYS_ADDRESS_2, SYS_ADDRESS_3) AGAINST ('+data')
, which will return all records with the word data
in any of the fields.
You can even query it without the index:
SELECT *
FROM FIN_LIVE.CUSTOMER_ADDRESSES
WHERE MATCH(SYS_ADDRESS_1, SYS_ADDRESS_2, SYS_ADDRESS_3) AGAINST ('+data' IN BOOLEAN MODE)
, but this will be much slower.
If you are looking for exact match in any of three fields, you may use this syntax:
SELECT *
FROM FIN_LIVE.CUSTOMER_ADDRESSES
WHERE 'data' IN (SYS_ADDRESS_1, SYS_ADDRESS_2, SYS_ADDRESS_3)
(works in all major databases).