Search code examples
mysqlbinarywhere-clausecollate

MySQL Case Sensitive Search Binary or Collate


I need to do a case sensitive search on a field in my database. I see some people suggesting the Binary approach.

SELECT * FROM car WHERE BINARY brand = 'Toyota'

Others are using the Collate approach

SELECT * FROM car WHERE brand COLLATE latin1_general_cs = 'Toyota'

I'm not sure which one to use? What's the better approach?


Solution

  • If you use utf8 characters binnary is best way to get case sensitive search.