问题描述:

Originally, I have 2 tables. I normalized it since the relationship of this tables is many to many. Now I have 3.

Jobs

  • jID PK
  • jName
  • jDesc
  • jEarnings
  • jTags

Course

  • cID PK
  • cName
  • cDesc
  • cSchool
  • cProgram

JobsCourse

  • ID PK
  • jID FK
  • cID FK

My app displays a tableview of the jobs

When clicked it displays the UIViewcontroller of jobs plus a tableview of the related course

How do I query the jobcourse table so that I can get all the related Courses to a certain job?

网友答案:

You can join the two tables, e.g.:

SELECT course.* FROM course INNER JOIN jobscourse ON jobscourse.cID = course.cID WHERE jobscourse.jID = ?

That gets all entries from course where the jID in jobscourse is equal to some value.

相关阅读:
Top