Mysql – How to do exact string match in SQL


I have two values in table PC and PC/name. But when I write a query,

select * from TransDetail TD where td.ModUserId like '%PC/%'

it gives me both results. Is there a way to get only one record?

Best Solution

You should make your WHERE clause like this:

select * 
from TransDetail TD
where TD.ModUserId ='PC'

This way you will get the results which are matched to 'PC' only.
The like that you made is giving your results of cases that PC can be start/middle/end of the field