We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Need a Query

cimscims
cimscims asked
on
Medium Priority
301 Views
Last Modified: 2012-05-11
I have 2 tables (tblQuestions and tblAnswers)
Column in the tables:
tblQuestions: QuestionId,Question
tblAnswers: AnswerId,QuestionId,Answer

I want a query with the results in a signle column as below:
Q: Where is Brooklyn bridge
A:  Los Angeles
      Washhington DC
      New York
      Chicago

Thanks in advance.  

Comment
Watch Question

As you choosed to use the Detail Grid in RadGrid so you don't need to get this data in one query.
Your main RadGrid will be bounded to Questions table and then on Child Grid bound, you will need to get QuestionID and filter answer based on it and display Answers in Child Grid.
Kindly correct if you are not working in Hierarchical RadGrid (Master-Detail RadGrid)?
CERTIFIED EXPERT

Commented:
select * from (
  select QuestionID, 0 as AnswerID, Question as Value
  from tblQuestion
  union
  select QuestionID, AnswerID, Answer as Value
  from tblAnswer
) tbl
order by 1,2

Author

Commented:
malikirfan28: I have plans to use Master-Detail Radgrid but i don't want the gridlines. I tried using Gridlines="None", it is not working. I think you have the format i was looking at in my earlier post. Please share your thoughts.
You can remove the Grid Lines by customizing the CSS (style template). It will remove all Grid Lines.
Jagadishwor DulalSenior Web Developer
CERTIFIED EXPERT

Commented:
Why not use a join query which select all answer from tblAnswers Where questionid=tblquestions.questionid

Author

Commented:
malikirfan28: I have a problem if i use the hierarchy grid. I have move the Question and Answers row up and down in the radgrid. That's why i am looking to keep the Question and Answers in the same column.
I am sure you can set the same format as you gave screen shot in another thread using RadGrid.

However I could not understand you here as what do you mean by row up and down?

Kindly note that you should understand how RadGrid populates its Detail (Child) Grid.

http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/hierarchyloadmodemixed/defaultcs.aspx

Author

Commented:
When the user selects the row and clicks on a up/down button, i have to move the rows up/down in the radgrid. Please see the below link for information:
http://www.telerik.com/community/forums/aspnet/grid/move-grid-rows-up-and-down.aspx
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
malikirfan28:
I have used the below link and i was able to

1) Move the rows up and down with the help of the below link
http://www.telerik.com/community/code-library/aspnet-ajax/grid/move-rows-up-down-using-radgrid-for-asp-net-ajax-prometheus.aspx

2) Format the grid as per the requirement. I wrote a Stored Procedure to get the Question and Answers to get into a single row.

I haven't tried your solution but my feeling is that would definetly work. Thank you for your time.


Move-Rows-up-and-down.png

Author

Commented:
Thank you.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.