Advertisement
Guest User

Untitled

a guest
Aug 12th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. CREATE TABLE audit_trail (
  2. old_email TEXT NOT NULL,
  3. new_email TEXT NOT NULL
  4. );
  5.  
  6. INSERT INTO audit_trail(old_email, new_email)
  7. VALUES ('harold_gim@yahoo.com', 'hgimenez@hotmail.com'),
  8. ('hgimenez@hotmail.com', 'harold.gimenez@gmail.com'),
  9. ('harold.gimenez@gmail.com', 'harold@heroku.com'),
  10. ('foo@bar.com', 'bar@baz.com'),
  11. ('bar@baz.com', 'barbaz@gmail.com');
  12.  
  13. with iter2 as (
  14. with iter1 as (
  15. select old_email, new_email from audit_trail where old_email = 'harold_gim@yahoo.com'
  16. ) select a.old_email, a.new_email from audit_trail a join iter1 b on (a.old_email = b.new_email)
  17. ) select * from iter1 union iter2;
  18.  
  19. ERROR: syntax error at or near "iter2" at character 264
  20. STATEMENT: with iter2 as (
  21. with iter1 as (
  22. select old_email, new_email from audit_trail where old_email = 'harold_gim@yahoo.com'
  23. ) select a.old_email, a.new_email from audit_trail a join iter1 b on (a.old_email = b.new_email)
  24. ) select * from iter1 union iter2;
  25. ERROR: syntax error at or near "iter2"
  26. LINE 5: ) select * from iter1 union iter2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement