0

I Have a sender field. In that fields contain some set of rows like..

sender
----
Rubin
RUBIN

But i can select rubin. query:

select * from request where sender='rubin' 

This query output is:

Rubin
RUBIN

I need output is, query returns null value:

returns null value
rubinmon
  • 153
  • 3
  • 12

5 Answers5

1

Use binary for that column,

select * from request where BINARY sender='rubin'
Gulmuhammad Akbari
  • 1,986
  • 2
  • 13
  • 28
1

you can use the SQL "LIKE" key word,

for example:

select * from request where sender LIKE '%rubin%'
1
SELECT * FROM request WHERE CAST(sender_id AS BINARY) RLIKE '^rubin$';
Vinayak
  • 305
  • 2
  • 11
0

Easiest fix, you should use a BINARY of value.

select * from request where sender = BINARY 'rubin'

Refrerence

Community
  • 1
  • 1
Mayank Pandeyz
  • 25,704
  • 4
  • 40
  • 59
0

What is happening is; by default mysql will create columns that are not case sensitive. You need to specify whether a column is case sensitive while creating the table. The BINARY text can be added to any column you need to be case sensitive. So in your example. If you create the table like this

CREATE TABLE request
('id' int, 'sender' varchar(7) BINARY)

and then ran the query you used, it will return nulll

Running the query like Gulmuhammad and Mayank mentioned in their answer will also work.

schizovivek
  • 83
  • 1
  • 1
  • 8