Basically the sql would look like this:

select * from table where username='anything' and pw='1' or '1'='1'

We know that 'and' has precedence over 'or' so:

select * from table where (username='anything' and pw='1') or '1'='1'

So if the 'anything''s password is not '1' you will get the first row since '1'='1' is always true

UPDATE:

To get the result you want you have to change username value and so for password, I'm not sure but this is nearly the values you should inject:

username='anything ('

pw=1') or '1'='1'