mySQL get information from multiple tables in one query

后端 未结 3 1557
生来不讨喜
生来不讨喜 2021-01-06 05:23

I\'m terribly new to SQL, and cannot seem to get the desired information out, after trying a few different google searches, and reading through some SQL tutorials.

I

3条回答
  •  星月不相逢
    2021-01-06 05:50

    You will need to use a JOIN statement to retrieve fields from multiple tables. http://www.w3schools.com/Sql/sql_join.asp

    SELECT Activity.Who, Activity.What, Comments.When, Comments.Comment FROM Activity JOIN Comments ON Activity.ID = Comments.ID JOIN Tasks ON Comments.ID = Tasks.ID WHERE Tasks.Status = 'Closed'
    

    Also, you're table structure looks to have a little redundancy.

提交回复
热议问题