Hi All,
I am trying to query a mysql database using the 'LIKE' keyword within my query based on what the user has input.
It works if I pass the string, however I am having trouble getting it to expand the parameter when combining it with the LIKE MySQL keyword.
As seen below parameters work in a simple SELECT without 'LIKE':
- string sql2 = "SELECT * FROM vocab WHERE english LIKE '%" + english + "%'";
-
string sql3 = "SELECT * FROM vocab WHERE english LIKE '%" + "@English" + "%'";
-
string sql4 = "SELECT * FROM vocab WHERE english =@English";
sql2 and sql4 both work and return data when entered through my application window. However sql3 doesn't as it doesn't seem to expand @English into whatever I have entered.
The single quotes around the % symbols are probably the cause but I can't figure it out.
Could someone please tell me the correct syntax for the statement in sql3?