Ausführen von SQL funktioniert in psql nicht

Ich versuche Folgendes auszuführen:

SELECT user_id, 0 post_id, current_timestamp granted_at 
FROM badge_posts  
WHERE (:backfill OR user_id IN (:user_ids) OR 0 NOT IN (:post_ids) )
GROUP BY user_id 
HAVING count(*) > 1000

aber ich erhalte einen Fehler bei :backfill. Kann mir jemand sagen, warum?

Ich weiß, dass dieser SQL-Befehl früher bei der Erstellung von Abzeichen ausgeführt wurde.

Anything starting with a : is a named parameter meant to be replaced by mini_sql prior to being sent to the DBMS, it’s not valid SQL by itself.

Example, see [2] below:

[1] pry(main)> User.find_by(username: 'anon43915857').id
=> 5

[2] pry(main)> DB.query(
  "SELECT id FROM users WHERE username = :username",
  { username: 'anon43915857' }
).first.id
=> 5

[3] pry(main)> DB.query(
  "SELECT id FROM users WHERE username = ?",
  'anon43915857' 
).first.id
=> 5
3 „Gefällt mir“

Thank you. This is clear.

1 „Gefällt mir“

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.