[thelist] mysql join and subqueries

partyarmy partyarmy at gmail.com
Fri Jun 3 21:32:56 CDT 2005


having trouble with a complicated (for me) sql statement.

SELECT members.member_id 
FROM members 
LEFT JOIN profile 
ON members.member_id=profile.member_id 
WHERE members.city = 'vancouver' AND profile.category_id = '0' AND
profile.profile_data LIKE '%three%'
LIMIT 0, 20

so far this works great, but, i need to take the result set, which
will be a bunch of member_id's and do this query.

SELECT COUNT(member_id) FROM logins WHERE member_id = ???????;

where the ??????? are the member_id's from the JOIN above. then, order
by the total number of logins.

not sure if this can be done without using subqueries for my server is
still reluctant to upgrade.

any help will be greatly appreciated. thanks guys.

codi lechasseur


More information about the thelist mailing list