How to use case sensitivity in instr() in MySQL?


Problem :

Possible duplicate: How to apply wildcard in instr() in MySQL?

The possible duplicate linked shows a query which is exactly like my current one sort of. However, I cannot find a way to make it a case sensitive match. :\

SELECT COUNT(*) FROM users WHERE INSTR(flags, 'T') > 0;

I get a count of 46 which is obviously wrong. It's counting every instance "T" in flags whether it's upper- or lower-case.

It works as according to the MySQL documentation. I found something in the MySQL docs that said to put an "@" symbol on a variable to make it a case sensitive match. However, I tried this on the @'T' to form the following query:

SELECT COUNT(*) FROM users WHERE INSTR(flags, @'T') > 0;

I get a count of zero.

Could anyone shed some light on this for me? :)

EDIT:

Forgot to mention, sorry. I also tried a LIKE '%T%' as the where-clause, which still failed and returns the same as (INSTR(flags, 'T') > 0);



Solution :

Tested,

SELECT binary 'AKkRBbagSsPpCtmxeGhUX' LIKE '%T%';

produces '0', as expected. According to the String Comparison documentation, LIKE performs a binary (thus, case-sensitive) comparison if either of its operands are binary.


Mysql Tutorials

Mysql Howto..

How to determine if MySQL UPDATE actually matched any rows with WHERE clause?

How to find the A and B where B value can be A value using mysql

How to select last date in 2 record in Mysql

How to use MySql MAX() in a WHERE clause

How to use REGEXP in MySQL to aquire specific columns

Mysql insert data in existing table. how to automaticly give the data new id if already exists

Mysql: How can I structure a table to hold usernames of various social networks?

How to get unique rows based on one column using joins in mysql

how do i update new latitude and longitude when existing google marker move to another place

How can I make an android app for a website I do not own?

show best matches in a mysql tag system

How to do Pivot in MySQL where only one column is the base of the query

How to query a MySQL field that has a string containing a double pipe?

How to escape this mysql query in php script?

PDO how do I returns the total number of executed queries

How to configure mySQL on Eclipse EE (Java)

How can I combine 2 columns in sql table to search for full names

Mysql: How to swap data of one column between rows?

how to add a MySQL Command to every page

MySQL query for weighted voting - how to calculate with values assigned to different columns

PHP How to check if a string already exists in a MySQL table

how to prevent from getting wrong ID

how to enable multi-thread/connection modify the same mysql table?

How to configure Doctrine in symfony2?

How to optimize mysql query?

How to add comments section to php website

How To Simplify This PHP IF into MySQL WHERE?

mysql- How to Update a record only under a specific condition?

How to get a list of rows from a database

How to create MySQL user with limited privileges?