There are three tables involved with this query.
Table1:
app_id | app_name | menu_id |
---|---|---|
1 | BigApp | 1 |
2 | smallApp | 2 |
3 | theApp | 2 |
Table2:
menu_id | menu_title |
---|---|
1 | menu1 |
2 | menu2 |
Table3:
user_id | app_id_list |
---|---|
1 | 1,2,3,4,5 |
2 | 1,3,5 |
So I want to grab the app_name, menu_title and then add another column (user_status, where would 1=on, 0=off) to verify that the app_id shows up in the app_id_list for a given user. The results for user_id = 2 would be:
app_name | menu_title | user_status |
---|---|---|
BigApp | menu1 | 1 |
smallApp | menu2 | 0 |
theApp | menu2 | 1 |
The SQL statement I've got so far is:
SELECT Table1.app_name, t2.menu_title
FROM Table1
INNER JOIN Table2 AS t2 ON (t2.menu_id = Table1.menu_id)
Not sure how to find the last column of data from Table3. Any thoughts?