Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL case sensitive string comparison with like and "="

i have one table named category.

in this table i have two columns 1.) cat_id, 2.) cat_name

in this table i have added record with this value : cat_id = 1, cat_name = test

Now when i am going to run select query

SELECT * FROM category WHERE cat_name = 'Test'

this query returns me null result because in database record string is test and in query it's a Test mark the differance of capital string here. Instade of null result i want the result with 1st record.

also i want same result in vice versa small and capital string.

i am using sqlite as database.

like image 866
Bhavin_m Avatar asked Jul 15 '26 01:07

Bhavin_m


2 Answers

Use upper function.

SELECT * FROM category WHERE upper(cat_name) = upper('Test')
like image 104
hkutluay Avatar answered Jul 17 '26 14:07

hkutluay


SELECT * FROM category WHERE cat_name = 'Test' COLLATE NOCASE;
like image 38
Yaqub Ahmad Avatar answered Jul 17 '26 14:07

Yaqub Ahmad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!