Hey everyone. My abilities to write enhanced SQL statements are very lacking and was wondering if I could get some assistance. I will explain what I have, then ask my question...
I am using DBManSQL and use it for a Marine Corps guestbook. Currently there are 45,700 records in the guestbook. There are 4 tables in the guestbook db, 2 of which are guestbook and guestbook_users. These 2 tables are linked by the username field and should be a 1:1 ratio with the amount of records in each table (one user record for one guestbook record). There are 53,000 records in the guestbook_users table...7,300 more than in the guestbook. This is due to user records that aren't linked to guestbook records because of bad email addresses when the user signed up for an account!
I know how to write a statement to show me each user record that has a corresponding guestbook record:
SELECT guestbook_users.username, guestbook.userid FROM guestbook_users JOIN guestbook WHERE guestbook_users.username = guestbook.userid
What I need to know is an SQL statement that will compare the two tables and show me records from each table that DON'T have a matching record in the other table so I can delete these records! Any help is greatly appreciated!
AJ
Webmaster, TheFew.com
http://www.thefew.com
Semper Fi, Do or Die!
I am using DBManSQL and use it for a Marine Corps guestbook. Currently there are 45,700 records in the guestbook. There are 4 tables in the guestbook db, 2 of which are guestbook and guestbook_users. These 2 tables are linked by the username field and should be a 1:1 ratio with the amount of records in each table (one user record for one guestbook record). There are 53,000 records in the guestbook_users table...7,300 more than in the guestbook. This is due to user records that aren't linked to guestbook records because of bad email addresses when the user signed up for an account!
I know how to write a statement to show me each user record that has a corresponding guestbook record:
SELECT guestbook_users.username, guestbook.userid FROM guestbook_users JOIN guestbook WHERE guestbook_users.username = guestbook.userid
What I need to know is an SQL statement that will compare the two tables and show me records from each table that DON'T have a matching record in the other table so I can delete these records! Any help is greatly appreciated!
AJ
Webmaster, TheFew.com
http://www.thefew.com
Semper Fi, Do or Die!