什么是正确的查询?

Im trying to figure out how my query should look like.

With this query i select * from usr_time_reg
WHERE usr_time_nr = '$usr_time_nr' AND usr_stamp_in LIKE '$y_m'

So far, so good!
Now i'd like to also select usr_stamp_in WHERE usr_stamp_in = '0000-00-00 00:00:00' AND usr_stamp_out = '$y_m

How should that query look like?
Query downunder is selecting ALL usr_stamp_in that contains '0000-00...'
I still need the filtering with "time_nr & y_m"!

//Make the Select in mysql
$query = "SELECT * FROM usr_time_reg
                   WHERE usr_time_nr = '$usr_time_nr' AND usr_stamp_in LIKE '$y_m'
                   OR usr_stamp_in = '0000-00-00 00:00:00' AND usr_stamp_out LIKE '$y_m'
                   ORDER BY usr_stamp_in DESC";

Variables

$y_m = "2015-03%";
$time_nr = "1";

db

ID  time_nr        stamp_in                stamp_out
1    1        2015-03-03 06:00:00     2015-03-03 15:30:00
2    1        0000-00-00 00:00:00     2015-03-04 15:30:00
3    1        2015-03-03 06:00:00     0000-00-00 00:00:00

I think everything you are wanting to do can be done down in the WHERE statement.

My best guess is:

SELECT *
FROM usr_time_reg
WHERE 
    usr_time_nr = '$usr_time_nr'
    AND
    (
        usr_stamp_in LIKE '$y_m'    
        OR
        (
            usr_stamp_in = '0000-00-00 00:00:00' 
            AND 
            usr_stamp_out = '$y_m'
        )
    );

Here usr_time_nr will always have to be '$user_time_nr' and then either one of the conditions seperated by OR will need to be true.