I have a question and maybe its simple (for you Guru).
I am moving my SQL Paging class from C # to the MySQL stored procedure. In my C # home object, the query is dynamically built based on criteria. Example:
if(keywords is not null) { whereClause += "WHERE description LIKE '%keywords%'" } if(price is not null) { whereClause += "AND price = '%price%'" }
....
string query = "SELECT col1, col2 FROM tblThreads " + whereClause
Now, my question is: how to make a dynamic where clause in MySQL look like this? Rather, if they do not enter anything for these parameters, how can I tell MySQL in the Stored Procedure to skip these? IE:
SELECT col1, col2 FROM tblThreads
Something like this work if these parameters were empty?
SELECT col1, col2 FROM tblThreads WHERE (IS NULL @keywords OR description like '%@keywords%'
??
Thanks guys.
source share