Skip to content

How to SELECT by BLOB primary key #78

Answered by zombiezen
thedmdim asked this question in Q&A
Discussion options

You must be logged in to vote

I think your Go logic is correct, but I think your SQL query is off. Since it's an INNER JOIN, if there are zero likes or dislikes, you won't get result rows.

SELECT
  cams.addr,
  cams.adminka,
  cams.stream,
  cams.model, 
  cams.country,
  (select count() from reactions where "like" = 1 and cam_id = cams.id) AS likes,
  (select count() from reactions where "like" = 0 and cam_id = cams.id) AS dislikes
FROM cams
WHERE cams.id = ?

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@thedmdim
Comment options

Answer selected by thedmdim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants