I need to figure out some clever MySQL snippet that will allow me to easily see two tables, the ids in the table if they exist or NULL or empty if they don't exist.
I have a users table and a legacy table and outside of manual comparison I can't figure out how to make them appear in a table together so I can compare. What I would love to see is something like this:
+----------------------------+
| user_id | email | uid |
| 14 | [email protected] | 26 |
| 16 | [email protected] | NULL |
+----------------------------+
I know there's a way to include NULL or empty values but I'm not sure what it is. Here's my deranged SQL query so far, yes, I know it's horrible to do subselects inside of subselects:
select uid from users where mail IN (
select email from legacy_users where id NOT IN (
select sourceid from migrate_map_users
)
);
There are three tables involved here, legacy_users => migrate_map_users => users
. The middle is just an m2m which joins the two. legacy_users and users both have an email column. and their own version of an id.
Thank you all!