Proper SQL Statement

  • Good Morning! Signed up for the daily newsletter and finally decided to stop lurking and post something on the forums 😀

    I would like to start out by saying I did not create this database schema or table. It was created by the program I am working with. I'm still unsure of the correct syntax when writing queries so I have a question!

    I'm sure some of you are familiar with DotNetNuke as that is what I'm using to run our intranet site at the moment. I create surveys using a third party module and the module creates a table in the DNN database for ALL of the responses. I have 19,500 responses in this single table alone (whew!). Its set up so each question I make gets a unique ID, as seen in the second column (pic below).

    My question: If I use the following select statement:

    Select Response from DynamicForms_QuestionResponse where DynamicQuestionID in ('9de72206-6333-4b39-8f2d-f11f372d8edb')

    I get one of the answers from one of the questions on a form I have created. What do I have to add to the statement to have it pull multiple IDs from the same column? I want to display multiple responses based on the unique IDs in the DynamicQuestionID column.

  • acogswell (9/3/2009)


    Good Morning! Signed up for the daily newsletter and finally decided to stop lurking and post something on the forums 😀

    I would like to start out by saying I did not create this database schema or table. It was created by the program I am working with. I'm still unsure of the correct syntax when writing queries so I have a question!

    I'm sure some of you are familiar with DotNetNuke as that is what I'm using to run our intranet site at the moment. I create surveys using a third party module and the module creates a table in the DNN database for ALL of the responses. I have 19,500 responses in this single table alone (whew!). Its set up so each question I make gets a unique ID, as seen in the second column (pic below).

    My question: If I use the following select statement:

    Select Response from DynamicForms_QuestionResponse where DynamicQuestionID in ('9de72206-6333-4b39-8f2d-f11f372d8edb')

    I get one of the answers from one of the questions on a form I have created. What do I have to add to the statement to have it pull multiple IDs from the same column? I want to display multiple responses based on the unique IDs in the DynamicQuestionID column.

    If the DynamicQuestionID is unique then using it to query the table will only return 1 row per DynamicQuestionID. You can specify more DynamicQuestionIDs in the "in" clause as such:

    Select Response from DynamicForms_QuestionResponse where DynamicQuestionID in ('9de72206-6333-4b39-8f2d-f11f372d8edb','AAAAA-AAAA-AAAA-AAA-AA','BBBB-BBBB-BBBB-BBBB')

    Does that answer your question?

  • Ah, the simple comma. Thanks for your response, that did it 😀

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

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