The users_enrolled_courses contains a reference to course_id and to users_id. So if there’s a record in there combining user John with course A - then John owns course A.
How do I achieve this goal with the repeat on the page?
I think I need to feed the repeat expression an array of all courses, which has an extra field on if it’s owned or not?
*Edit: I tried with the new manipulations in server connect - but that only gives me the owned courses again
That's good. Sounds like you now know how its working. This is time invested.
I would recommend to take a small SQL course if you are new to this.. will help a lot when your app scales, you need complex reporting and complex features and you start to build custom queries in the server actions.
Haha thanks, you’re very right. Slowly becoming a full fledged programmer last few weeks… been learning a lot about node, express and now SQL. Only downside is that the development isn’t going as fast as I wanted it to go… but it should be an exponential curve.
Going to try out doing 2 left joins now as you suggested!
Probably because those course are owned by someone else… So there is no row which has user id as null for them.
Looks like you might need to create custom query for this. The solutions I suggested so far could have been created via query builder, but not this one…
The query you have in dbeaver, add condition user_id = 37 in the join itself. And remove conditiin from below.
See if that works.
You should put the OR condition in brackets for sanity.
So how it would read is join on (courses.id = course_id AND (user_id = 22 OR user_id is NULL)).