Advertisement
metalni

sql query

Nov 3rd, 2022
1,277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. INSERT INTO competitions (user_id, headline, description, start_date, end_date, competition_artwork)
  2. SELECT ${user_id}, ${headline}, ${description}, ${start_date}, ${end_date}, ${competition_artwork}
  3. WHERE NOT EXISTS
  4.     ( SELECT DISTINCT competitions
  5.         FROM competitions
  6.         WHERE id = (SELECT MAX(id) FROM competitions) and user_id = ${user_id} and headline = ${headline} and description = ${description} and start_date = ${start_date} and end_date = ${end_date} and competition_artwork = ${competition_artwork}
  7.     ) RETURNING *;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement