Get items in many to many relationship table

  • background.

    First a user picks questions that relate to event that then gets saved in a many to many relationship table. many questions can go towards one event and one event can have many questions. My problem lies in trying to repopulate and edit page with the checkboxes that where filled witht he data from the many to many table. I am trying to do one sql query that gets me all the questions in case they want to add more and the ones they alread picked. The following is the table sctructures

    tblSrp

    intSrpId

    strSRpName

    dtLogged

    bitACtive

    tblQuestion

    intQuestionId

    strQuestion

    dtLogged

    bitActive

    tblSRPCreate

    intSRPID

    intQuestionId

    The follwoing gets me nothing???

    Select distinct sq.intQuestionID,

    sq.strQuestion

    from tblSRPQuestion sq INNER JOIN

    tblSRPCreate sc on sc.intQuestionId = sq.intQuestionId

    where bitActive = 1 AND

    intCategoryID = 1

  • This was removed by the editor as SPAM

  • HI,

    ok I am getting the question that where picked for this srpId. What I don't know how to so is there a way to get all questions and then create a secondary field that picks the questions that are in table srpCreate to rotate through and add the checkbox check. or do I need to make 2 queries. 1 to populate the page with questions and then one to go through and check the ones that where checked in tblsrpCreate.

    Select distinct sc.intQuestionID,

    sq.strQuestion

    from tblSRPQuestion sq INNER JOIN

    tblSRPCreate sc on sc.intQuestionId = sq.intQuestionId INNER JOIN

    tblSRP s on s.intSRPId = sc.intSrpId

    where sq.bitActive = 1 AND

    s.intSrpId = 125

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply