I'm trying to figure out how to limit this query by a field in another table (registrations). The field is called 'paid'. I need to only return a row if the new camper has paid more than $149. The attached code is working fine, but does not limit the query by this field in the registrations table. The connecting key between the tables (clients and registrations) is client_id.
My feeble attempts at this are resulting in an error of "The SELECT would examine more than MAX_JOIN_SIZE rows". Have I given all the information needed to solve this little puzzle?
Thanks in advance to anyone who helps out.
SELECT newcampers.referred_by AS referred_by, newcampers.client_id AS new_id, newcampers.firstname AS new_first, newcampers.lastname AS new_last, referringcampers.client_id AS referring_id, referringcampers.firstname AS referred_first, referringcampers.lastname AS referred_last FROM clients AS newcampers LEFT JOIN clients AS referringcampers ON (newcampers.referred_by=referringcampers.email) WHERE newcampers.referred_by != '' AND newcampers.referral_paid != 1 ORDER BY newcampers.lastname