In addition to what the others said about using "LIKE", I
would like to add two things:
- You may also use
a FULLTEXT search. A bit more complex, but much more effective.
- You are fetching single records and pushing each column
of them into an array. You'll get a flat array of all your
dataset. Are you sure this is what you want?
For example, if your data is the following:
| Field1 | Field2 |
| aaa1 | bbb1 |
| aaa2 | bbb2 |
| aaa3 | bbb3 |
After your loop, it will produce an array like
@array = (
"aaa1\n",
"bbb1\n",
"aaa2\n",
"bbb2\n",
"aaa3\n",
"bbb3\n"
);
Perhaps you should consider
fetchall_arrayref instead. For more guidance, you may refer to DBI recipes.