I want to find a word in my list of tags. They can be at the beginning, end or middle so i tried writing.
Where name like "%@0%"
That didnt work so i tried
@"LIKE ""%" + MySql.Data.MySqlClient.MySqlHelper.EscapeString(q) +@"%"
I thought that worked so i tried searching %. The results showed up all my tags, i expected only tags with % in them (so that would be none ATM).
How do i escape strings properly? and use it to search the middle of text?
-edit-
The solution is the below. I ran it against a few test and it passed them all. The query is
... where n.name LIKE CONCAT("%", @some_name , "%") ...;
then in code
cmd.Parameters.AddWithValue("@some_name", val.Replace("\\", "\\\\").Replace("_", "\\_").Replace("%", "\\%")));