On Sun, Jan 03, 2021 at 12:53:03AM -0800, Alexander Mills wrote: > rows, err := c.Database.Db.Query(` > > select *, ( > select count(*) from mbk_file_label > where file_id = mbk_file.id and label_id IN ( > select id > from mbk_user_label > where label_name IN ( > $2 > ) > ) > ) as xxx > from mbk_file > where user_id = $1 > order by xxx DESC > `, > loggedInUserId, > labelStr, > ) > > > then the query doesnt work and I dont know why?
You might want to debug log your statements in the database engine... What you want to do is not what it's doing. You ask the sql engine to escape the input you give it. So your question becomes `where label_name in ('"carnivore", "mammal", "vertebrate"')` Meaning the string exactly as given as single element. Maybe that helps: https://stackoverflow.com/a/38878826/6212932 if you use postgres. Cheers, Reto -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/20210103092831.l2wlvdshifdzsce3%40feather.localdomain.