Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
edited tags
Link
user330315
user330315
added 3 characters in body; edited title
Source Link
marc_s
  • 760k
  • 186
  • 1.4k
  • 1.5k

SQL RetriveRetrieve rows that have all rows from other table

I am facing some issues retrieving data using SQL in one specific scenario:

Suppose I have the following tables:

A(id, attr_a, attr_b); B(id, attr_d, attr_e); C(id_a, id_b); 
  • A (id, attr_a, attr_b);
  • B (id, attr_d, attr_e);
  • C (id_a, id_b);

As you can see, table C have FK referencing id from table A, and referencing id from table C.

I need to retrieve table A rows that for each A row relates to every B row.

In a real life scenario, assuming A means users, B means privelegesprivileges, and C is the many to many entity that relates users with privileges, I would want to get only users that have ALL privileges

SQL Retrive rows that have all rows from other table

I am facing some issues retrieving data using SQL in one specific scenario:

Suppose I have the following tables:

A(id, attr_a, attr_b); B(id, attr_d, attr_e); C(id_a, id_b); 

As you can see, table C have FK referencing id from table A, and referencing id from table C.

I need to retrieve table A rows that for each A row relates to every B row.

In a real life scenario, assuming A means users, B means priveleges, and C is the many to many entity that relates users with privileges, I would want to get only users that have ALL privileges

SQL Retrieve rows that have all rows from other table

I am facing some issues retrieving data using SQL in one specific scenario:

Suppose I have the following tables:

  • A (id, attr_a, attr_b);
  • B (id, attr_d, attr_e);
  • C (id_a, id_b);

As you can see, table C have FK referencing id from table A, and referencing id from table C.

I need to retrieve table A rows that for each A row relates to every B row.

In a real life scenario, assuming A means users, B means privileges, and C is the many to many entity that relates users with privileges, I would want to get only users that have ALL privileges

Source Link
Rogger Fernandes
  • 915
  • 4
  • 16
  • 28
Loading