Post AMdW6vr80nEYtSLPai by vel@mastodon.ml
 (DIR) More posts by vel@mastodon.ml
 (DIR) Post #AMdUA7xXGhvrOLjlho by drq@mastodon.ml
       2022-08-18T00:40:37Z
       
       0 likes, 0 repeats
       
       So I have this huge MySQL query, which takes 12 input parameters, but all of them are 8 instances of value X and 4 instances of value Y. They're all in different places of the huge query.How do I bind variables to that in Go in an SQL-safe way?I see the syntax of "?" but it's not really named, so it works if you have one or two unique parameters, not 12 recurring ones.
       
 (DIR) Post #AMdW6vr80nEYtSLPai by vel@mastodon.ml
       2022-08-18T01:02:27Z
       
       0 likes, 1 repeats
       
       @drq прочитала gulag
       
 (DIR) Post #AMdbWbn9jQBNxwY6pU by dside@mastodon.ml
       2022-08-18T02:03:08Z
       
       0 likes, 0 repeats
       
       @drq я не уверен, насколько это хорошая идея, но в голову приходит CTE с селектом констант:https://dev.mysql.com/doc/refman/8.0/en/with.html#common-table-expressionsТак можно дать им в рамках запроса локальные имена, но снаружи передать всего единожды.Наверное. У меня в голове это вроде имеет смысл, начал что-то может иметь смысл в 5  часов утра :blobcatgooglyholdingitsheadinitshands: Или вот такого рода хохма:> SELECT … FROM …>   INNER JOIN (SELECT ? AS l1, ? AS l2) locals>     ON true> WHERE c1 = l1 AND c2 IN (l1, l2)
       
 (DIR) Post #AMdoHRspaUg8IOIz1U by bemyak@lor.sh
       2022-08-18T04:25:52Z
       
       0 likes, 0 repeats
       
       @drq IIRC, instead of `?` you can use `$1`, `$2` and so on.If you're tired of writing SQL strings by hand, we maintain the sqrl project at my current job:https://github.com/SharperShape/sqrlIt's a bit nicer than concatenating strings with possible typos all the time :)
       
 (DIR) Post #AMeMcZ1vbm14z2ngae by drq@mastodon.ml
       2022-08-18T10:50:42Z
       
       0 likes, 0 repeats
       
       @bemyakI tried $1 and $2, doesn't work.
       
 (DIR) Post #AMgD0wuBRE8B5XfTAu by bemyak@lor.sh
       2022-08-19T08:12:34Z
       
       0 likes, 0 repeats
       
       @drq yep, sorry, it works in Postgres, not in MySQL. Have you tried `?1` ?