I have used the next SQL statement in both MySQL and PostgreSQL, but it fails in PostgreSQL
db.Query(`SELECT COUNT(*) as N FROM email WHERE address = ?`, email)
with this error:
pq: F:"scan.l" M:"syntax error at end of input" S:"ERROR" C:"42601" P:"50" R:"scanner_yyerror" L:"993"
What's the problem? The error messages in PostgreSQL are very cryptic.
psql
.PREPARE q AS SELECT COUNT(*) as N FROM email WHERE address = $1;
thenEXECUTE q;
.$1
is the placeholder syntax forPREPARE
, but your programming language probably uses?
; otherwise there's no difference.