Q:

mysql compare two tables

I have a mysql database that has 2 table.  the first table contains the user information, and the second table contains the votes.  there is a common field between the two (userid). 
but after checking the num rows in each table I found that the first table contains nearly 1000 users more than the second, so there are almost 1000 members whio didn't vote. 
I want to query the two tables and get an array containing the userid of the members who didn't vote. 
How to? 
Thanks. 

A:

You need to join both tables and filter out which users don't have corresponding record in votes table. 
SELECT id FROM members
LEFT JOIN votes ON userid=id
WHERE votes.userid IS NULL

