Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I do a case sensitive comparison in sql?

Tags:

syntax

sql

Just started a tutorial in SQL for beginners. I'm doing some exercises now and I would like to know how to change the title.

If you look at here: you'll see that I have made firstname, lastname, title, age and salary. And I wrote the letters in small letter. How can I change it to capital letter?

http://tinypic.com/r/amtpgm/3

I tried using this:

update mytablename 
set firstname = 'Firstname'
where firstname = 'firstname'

But I later realized that this one will not work.

Thanks

====

additional question:

I also notice that if I wrote with spaces, then its not recognized. It's the first part only which will be displayed. Do you know why is it doing? Thanks

create table myemployees_tr0214
(First Name varchar(20),
Last Name varchar(20),
Title char(5),
Age number(3),
Salary number(6,10));

==========

thank you for all your inputs. I've tried this one in renaming the "Firstname" to "Fname" and it didn't work. Did I miss something?

alter table myemployees_tr0214
rename column Firstname to Fname;
like image 491
tintincutes Avatar asked Jul 22 '26 19:07

tintincutes


1 Answers

This should update all the firstnames in the table to an uppercase first letter:

UPDATE mytablename SET firstname = CONCAT(UCASE(MID(firstname,1,1)),MID(firstname,2));

Hope this helps you :)

like image 126
pjau Avatar answered Jul 24 '26 08:07

pjau