CREATE TABLE event (
id SERIAL PRIMARY KEY,
city VARCHAR ( 30 ),
author_id INT REFERENCES users (id) NOT NULL,
text VARCHAR,
cDate TIMESTAMPTZ NOT NULL DEFAULT NOW(),
uDate TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE TYPE InviteStatus AS ENUM ('pending', 'approved', 'declined');
CREATE TABLE invite (
sender_id INT REFERENCES users (id) NOT NULL,
receiver_id INT REFERENCES users (id) NOT NULL,
event_id INT REFERENCES event (id) NOT NULL,
receiver_approved InviteStatus DEFAULT 'pending' NOT NULL,
cDate TIMESTAMPTZ NOT NULL DEFAULT NOW(),
uDate TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
我们有两个表。我们获取userId,即sender_id。如果userId = sender_id作为来自外部的参数存在于invite表中,并且www.example.com = invite.event_id,我们需要从event获取所有列,并在结果中从invite创建字段receiver_approvedevent.id
1条答案
按热度按时间irlmq6kh1#
其中
userID
是来自外部的参数