Regexp in mysql

wxdqz

New Member
I need to write a query for a search form.

User can limit search by selecting some options from dropdown menus.

E.g. SELECT * FROM tbl WHERE state = 'NY';

User may also choose not to select any options, i.e. do a wildcard search.

In that case, how can I write the query with a WHERE clause, and still be doing a wildcard search.

Would the following be correct in that case:

SELECT * FROM tbl WHERE state LIKE '%';

I know it's easier to just drop the WHERE clause, but there's a reason why I need to have it in the query. Too long to explain.

Thanks.

Richie.
 
Back
Top