Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE Users(
- uid int PRIMARY KEY,
- name text,
- phone text
- );
- CREATE TABLE Messages(
- recipient int REFERENCES Users(uid),
- sender int REFERENCES Users(uid),
- time timestamp NOT NULL,
- message text NOT NULL,
- PRIMARY KEY (recipient, sender, time)
- );
- SELECT COUNT(distinct U2.uid)
- FROM Users U2,Messages M
- WHERE M.sender=U2.uid AND U2.name<>'Freddy' AND M.recipient=(SELECT U.uid FROM Users U,Messages M
- WHERE M.recipient=U.uid AND M.sender=(SELECT uid FROM Users where name='Freddy'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement