I need to get all rows in which eventname field contains this text (including single quote)
's Birthday
I tried this but it is giving error:
select * from fab_scheduler where eventname like '%\'s Birthday%'
How do i construct such query?
Thanks
If you intend to include ‘s in your SQL, you need to escape it:
Additionally, if you are constructing the SQL in a program, you should strongly consider escaping variables that go into SQL queries by using
mysql_real_escape_stringor its equivalent in your programming language. Failure to do so will make your application vulnerable to SQL injection attacks by whomever controls the data source for said variables (probably your users; keep in mind that “your users” can mean “the whole internet” depending on circumstances).Edit: Quoted the dev.mysql.com instructions above.