fixed query error when user has not reacted to post

This commit is contained in:
2024-06-11 20:35:23 +02:00
parent 2ca997fca9
commit 8943641baf

View File

@@ -73,7 +73,7 @@ public class Routes {
(SELECT * FROM comments inner join posts ON comments.child = posts.id) com
inner join targets ON targets.id = com.parent
)
SELECT targets.*, reactions.positive AS reaction FROM targets, reactions WHERE targets.id = reactions.post AND reactions.userid = (?);""");
SELECT * FROM targets LEFT JOIN (SELECT post, positive as reaction FROM reactions WHERE userid = (?)) ON post = id;""");
stmt.setObject(1, longitude);
stmt.setObject(2, latitude);
@@ -178,7 +178,7 @@ public class Routes {
(SELECT * FROM comments inner join posts ON comments.child = posts.id) com
inner join targets ON targets.id = com.parent
)
SELECT targets.*, reactions.positive AS reaction FROM targets, reactions WHERE targets.id = reactions.post AND reactions.userid = (?);""");
SELECT * FROM targets LEFT JOIN (SELECT post, positive as reaction FROM reactions WHERE userid = (?)) ON post = id;""");
stmt.setObject(1, id);
stmt.setObject(2, User.getUserID());