0

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?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197

1 Answers1

0

After reviewing the following discussion:

Is storing a delimited list in a database column really that bad?

I have solved this issue by creating and expanding the Table3 where each value that was in the app_id_list now has its own row. Faster and can just link up with another JOIN.