Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return 0 rows instead of something else SQL

I have this simple database:

SecretaryID username password
1           marpap    marpap
2           eleko     eleko

And I do this query:

select username, password 
from Secretaries 
where username='marpap' and
      Password='marpap'

but it return 0 rows instead of 1. What is the problem?

like image 748
the essential Avatar asked Jun 20 '26 19:06

the essential


1 Answers

Try using LTRIM and RTRIM to remove spaces before or after your string.

where LTRIM(RTRIM(username)) = 'marpap'
and password = 'marpap'
like image 191
SQLChao Avatar answered Jun 23 '26 08:06

SQLChao



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!