MySQL where clause strangely returns all rows

Viewed 36

Someone tried SQL injection on my website. He/she didn't succeed, but something he/she tried caught my attention.

This where clause returns all rows and I have no idea why it does.

SELECT * FROM MyTable WHERE MyColumn=''=''

I tried this statement in MySQL and MariaDB, and they both returned all rows. Shouldn't this statement throw a syntax error? Why does it return all rows?

1 Answers

Imagine this query:

select * from MyTable where false='';

Then, just divide yours in:

SELECT * FROM MyTable WHERE (MyColumn='')=''
Related