I have this:

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 (
'carnivore', 'mammal', 'vertebrate'
)
)
) as xxx
from mbk_file
where user_id = $1
order by xxx DESC
`,
loggedInUserId,
//labelStr,
)


the above works, but if I used labelString instead of the hardcoded version:


labelStr = "'carnivore', 'mammal', 'vertebrate'"

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 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/d3ae7861-7098-483b-86e3-04d7a0df0d6en%40googlegroups.com.

Reply via email to