SQL LIKE vs. Java indexOf()
843854May 18 2004 — edited May 19 2004Hi,
Conditions:
--
1. User can search records in the database by entering up to 10 parameters.
2. One of parameters are Key Words to search in any of 10 columns in a table.
3. Java generates SQL query dynamically, depending on the number of actually provided parameters.
-- Option 1
Java program will generate 10 LIKE conditions to search each Key Word in 10 columns (20 LIKEs/2 keywords, and so on).
-- Option 2
Java program will not generate LIKE statements. Java will read records using less SQL conditions, and then filter objects by calling String.indexOf(Key Word) 10 times per Key Word (20 LIKEs/2 keywords, and so on).
Database: MySQL 3.xx.xx
What is better in your opinion?
Evgeny
Javadesk