mysql - SQL Query Help 1 to N -


i have mysql database 1 n relation in there.

    sample data:     table user:     id,name     table entry:     id,name      table user_entry:     userid,entryid 

i entries (their id , name) , flag, states, if user id x has entry (via table user_entry)

you need select entry table entries, , left join user_entry table find out if particular user has entry:

select  e.id,          e.name,         case when ue.entryid null 0 else 1 end userflag    entry e         left join user_entry ue             on ue.entryid = e.id             , ue.userid = x 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -