I have 3 tables which are divided in users, user_courses and course.
I wanted to create 2 queries:
I got the first query done but I can´t make the 2nd query work.
I tried to negate the conditions and got the same rows multiple times.
SELECT
course.course_id,course_name,course_owner,course_date,course_time
FROM
course, users, user_courses
WHERE
usershortcut = "mmuster"
AND user_courses.user_id = users.user_id
AND user_courses.course_id = course.course_id
This is the first query which gives out all the subscribed courses of a user and I have no clue how to reverse it so I get the unsub courses of that user.
If the query you mention gives you the subscribed courses, for the second one you can use a filtering condition as in:
select *
from course
where course_id not in (
SELECT course.course_id
FROM course,users,user_courses
WHERE usershortcut="mmuster" and user_courses.user_id = users.user_id
and user_courses.course_id = course.course_id
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.