How to get data from 4 tables in 1 sql query?
问题 I have the following database schema: table courses: id tutor_id title table course_categories: id category_id course_id table categories: id name table tutors: id name table subscribers: id course_id user_id I need to make 1 sql to get a course with all it's categories, and the tutor for that course and the number of subscribers for that course. Can this be done in 1 query? Should this be done using stored procedures? 回答1: With this query you get what you want: select co.title as course, ca