I have 3 tables, one of accounts, one of friends and another of consumers. Something like this:
table_accounts
id | account_name
table_friends
id | account_id | people_id
table_consumers
id | account_id | people_id
I need to cross the following information:
Which consumer_id coexist in both tables, something simple like this:
SELECT
*
FROM
table_friends,
table_consumers
WHERE
table_friend.account_id = 12345
AND table_friend.account_id = table_consumers.account_id
GROUP BY table_friend.people_id
this query is very slow
Well, I now need to get what are the consumer_id's friends table, which are NOT in the consumers table. And in a third moment, find out which consumer_id does NOT exist in the friends table. But I think it's the same thing ...
My doubt is about logic, I can not think how to cross this information.