MySQL join empty rows
I'm trying to construct a simple query in for getting users with particular meta fields (this is in Wordpress, but doesn't matter cause it's raw sql)

A simple query i did looks like this

    SELECT * FROM wp_sb_users u
     LEFT OUTER JOIN wp_sb_usermeta m ON (u.ID=m.user_id)
     LEFT OUTER JOIN wp_sb_usermeta mm ON (u.ID=mm.user_id)
     LEFT OUTER JOIN wp_sb_usermeta mmm ON (u.ID=mmm.user_id)
    WHERE
     m.meta_key = "autostatus" AND
     mm.meta_key = "first_name" AND
     mmm.meta_key = "last_name"

though i have only one small trouble -- if `mmm.meta_key = "last_name"` doesn't exist at all, the row isn't returned.. i tried `mmm.meta_key <=> "last_name"` but then it takes any other meta_key (like "user_email") and puts there in row, which then results in having a user with first name Alex and last name my@email.com

I also tried (mmm.meta_key = "last_name" OR mmm.meta_key IS NULL), but it doesn't work too

Help me figure it out please
MySQL join empty rows
===

I'm trying to construct a simple query in for getting users with particular meta fields (this is in Wordpress, but doesn't matter cause it's raw sql)

A simple query i did looks like this

    SELECT * FROM wp_sb_users u
     LEFT OUTER JOIN wp_sb_usermeta m ON (u.ID=m.user_id)
     LEFT OUTER JOIN wp_sb_usermeta mm ON (u.ID=mm.user_id)
     LEFT OUTER JOIN wp_sb_usermeta mmm ON (u.ID=mmm.user_id)
    WHERE
     m.meta_key = "autostatus" AND
     mm.meta_key = "first_name" AND
     mmm.meta_key = "last_name"

though i have only one small trouble -- if `mmm.meta_key = "last_name"` doesn't exist at all, the row isn't returned.. i tried `mmm.meta_key <=> "last_name"` but then it takes any other meta_key (like "user_email") and puts there in row, which then results in having a user with first name Alex and last name my@email.com

I also tried (mmm.meta_key = "last_name" OR mmm.meta_key IS NULL), but it doesn't work too

Help me figure it out please