Many-to-many: select an entity by matching relationship
2
votes
2
answers
131
views
I have a many to many relationship implemented:
CREATE TABLE public.message (
id BIGSERIAL PRIMARY KEY,
name varchar(40) UNIQUE NOT NULL
);
CREATE TABLE public.package(
id BIGSERIAL PRIMARY KEY,
name varchar(40) UNIQUE NOT NULL
);
CREATE TABLE public.package_to_message (
message_id BIGINT NOT NULL,
package_id BIGINT NOT NULL,
CONSTRAINT package_to_message_pk PRIMARY KEY (message_id, package_id)
);
I need to select a package that has an association with a precisely defined set of messages
[message_name_1, message_name_2, message_name_3]
. With all of the above and none more.
Is it possible to do this using a more or less optimized query? Nothing comes to mind.
Asked by Александр
(23 rep)
Jul 21, 2024, 05:33 PM
Last activity: Jul 22, 2024, 11:07 PM
Last activity: Jul 22, 2024, 11:07 PM