出于某种原因,我觉得这是一项非常简单的任务,但我就是无法理解它。我有两张桌子。表 A 是称为公司的公司列表,表 B 是称为用户的用户列表。用户表有一个名为"access"的文件,它存储允许用户查看的所有公司的ID。
公司
id name
-- ----
1 coca cola
2 samsung
3 apple
4 microsoft
用户
id access name
-- ------ ----
1 1,3,4 brain owen
2 2,3 janet smith
2 1,2,4 peter pete
2 2,3,4 jane dow
我的问题是如何显示有权访问特定公司的用户列表? 例如可口可乐。谢谢。
id name
-- ----
1 coca cola
2 samsung
3 apple
4 microsoft
userId companyId
------ ---------
1 1
1 3
1 4
2 2
2 3
id name
-- ----
1 brain owen
2 janet smith
两个用户不能具有相同的 ID...
我想这会给你可口可乐的用户名
select name from users where access in(1)