php - Complex MySQL join with dynamic where -


here 2 tables i'm trying join...

    name: notifications ------------------------------------------- content | position | member  | contenttype ------------------------------------------- test  | manager  | testera | email test b  | manager  | testera | email test c  | manager  | testera | sms -------------------------------------------      name: position ----------------------------------------------- position  |  member  |  getsemail  |  getssms ----------------------------------------------- manager   |  testera |  1          |  0 employee  |  testerb |  0          |  1 ----------------------------------------------- 

i return rows "notifications" table member "testera", , contenttype "position" table equal "1". above table data, want first 2 rows "notifications" returned since contenttype of "email" allowed in position table.

is possible table structure?

try:

select n.* notifications n join position p    on n.member = p.member ,      case n.contenttype when 'email' p.getsemail                          when 'sms' p.getssms end = 1 n.member = 'testera' 

sqlfiddle here.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -