1

I have two tables that is :

  1. theatre(id,tname,taddress)
  2. movie(id,mname,tid).

In theatre table there is one record with id 1, like :

 1, Big Cinema, abc. 

And in moive table there are 3 record like :

1) 1, Race, 1.
2) 2, BMB, 1.
3) 3, SOTY, 1.

Now I want to show theatre name only one time and with all three movie.

1
  • How do you want them displayed? Also, what are the column names are in the second table? Commented Jul 30, 2013 at 10:02

2 Answers 2

4

Is this what you need ?

select [id],[tname],
    stuff((select ',' + CAST(t2.[mname] as varchar(10))
    from movie t2 where t1.[id] = t2.[tid]
    for xml path('')),1,1,'') SomeColumn
from theatre t1
group by [id],[tname]

SQL Fiddle

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks, I want to display data like : Theare name Movie : Big Cinema Race BMB SOTY
@VIPULPARMAR Check this Fiddle And the SQL Query for the same is select [tname] TheatreName, stuff((select ',' + CAST(t2.[mname] as varchar(10)) from movie t2 where t1.[id] = t2.[tid] for xml path('')),1,1,'') Movie from theatre t1 group by [id],[tname]
I want show this movie name in gridview. So it can be possible. Pls reply me.
I don't have C# code i want to design this. That has one gridview first Headerfield is theatreName, second Headerfield has another datalist and in datalist shows all movie name. So how it is possible pls reply me.! Thanks
Hi I wan't to design gridview inside another gridview with insert,update, and delete and table are 1) tbl_Show(ShowID{P},ShowTime,Silver,Gold, Platiniam,ShowTimeId) 2) tbl_STime(ShowTimeId{P},TheatreId,MovieId,FromDate,ToDate) 3) tbl_Theatre(TheatreId{P},TName,Taddress) I wan't to design same like this so visit www.codeproject.com/Articles/14293/Gridview-Inside-a-GridView-in-ASP-NET-2-0 so please help me thanks.
0

If did you mean to concatinate some columns in one column you can try

Select t.tname + ' ' + t.taddress as tNameAdress, m.mname 
from movie m inner join theatre t on m.tid = t.id

1 Comment

Thanks, I want to display data like : Theare name, Movie : Big Cinema, Race, BMB, SOTY

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.