What exactly does this do? What commands does this send to the sql server and what should/can follow the command. I think there is a UNION ALL command too. Sorry, I'm new to SQL and am learning. I do not know much more than SELECT and other things similar to that. Thanks.
Union is used to pull two matching datatypes together in one column. Let's say, for example, you have a forum. In the database for that forum you have two tables tblAdminUser and tblUser. You want to do a mass email to all users, so you can use union to pull out the email adress from both tables. Union pulls out distinct values. Union All shows the repeated values (if any). example: select email from tblAdminUsers UNION select email from tblUsers This would give you one list of all distinct email addresses in both tables.
You could use a JOIN query with something link SELECT DISTINCT(users.email) FROM admins JOIN users where admins.email = users.email GROUP BY users.email
Union returns distinct values. Union all returns all. Union create one column from two tables. JOIN creates a table that contains all columns from both tables. Be careful with JOINS in MySQL. Sometimes the JOIN happens before the where clause and sometimes after.