【发布时间】:2017-09-07 11:32:05
【问题描述】:
我有 3 张桌子,一张是账户,一张是朋友,另一张是消费者。 像这样的:
table_accounts
id | account_name
table_friends
id | account_id | people_id
table_consumers
id | account_id | people_id
我需要交叉以下信息:
两个表中同时存在哪个consumer_id,简单如下:
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
这个查询很慢
好吧,我现在需要获取consumer_id 的friends 表,这些表不在consumers 表中。在第三个时刻,找出friends 表中不存在哪个consumer_id。但我认为这是同一件事......
我怀疑逻辑,我想不出如何跨越这些信息。
【问题讨论】:
-
我不懂你的数据库架构,你最后的§不清楚你想要什么,请用你想要的字段名称和表之间的关系编辑你的帖子