SQL,Make Multiple values for multiple columns into one column separated by comma


I'm getting the result as this

Name       Class       Subject
Anju         10             Maths
Anju         10             Physics

How to write the query to get the result like this

Name       Class       Subjects
Anju           10          Maths,Physics




Please click "mark as answer" if this post helped you.
3/2/2009 8:25:00 AM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 17
Get it on Google Play
Get it on Apple App Store



Beware of bugs in the above code; I have only proved it correct, not tried it.
(Donald Knuth)
3/2/2009 9:09:24 AM
3/2/2009 9:22:17 AM

Similar Artilces:

SQL: mutiple rows one column to multiple columns one row
In InfoMaker SQL can you take a table with multiple rows for the same key and take a column from the rows and create mutiple columns with one report line with the key(no duplicate keys) on a report? For example Table books (key) (book title) 123 misery 123 titanic 123 roots 456 war 456 1984 456 giant The report I need would look like this Key title1 title2 title 3 123 misery titanic roots 456 war 1984 giant Thanks in advance. -- Kaye Hendry HealthInsight email:kaye.hendry@healthinsight.org ...

Display multiple columns in Gridview from One Column of SQL table
Hi I have a table in sql with 2 columns and I want to display that in multiple columns in Gridview. SQL Table No.            Type 1               A1 1               B2 2              A2 2               B2 3        &...

SQL Multiple values from one column query?
Hello, Im trying to make a query that returns data like so:I have the following columns; Name, Description, Link, Year, Sketched, Colouredin which Year is an Int, Sketched and Coloured are boolean and the rest are varchar(xx). Now I want a query in which I can choose to get something with the following values: Year either 2007 or 2008 , Sketched either true or false and Coloured is true.I tried something like this: SELECT Name, Description, Link, Year, Sketched, Coloured FROM ImageTabe WHERE (Year = @Year1 OR Year = @Year2 OR ...

update multiple columns in one sql statements
I am almost sure I can update variables columns in one select/case type statement, but having problems working out the syntax. I have a table with transactions - with tran types as the key. in this example, types = A,B,C ,D. in this first example I am updating the sum of QTY to value t_A based on tran types =A. can I perform sub query/case to update with the same where clause but for types B,C and D?? I also have to insert for specific lot numbers each sum values. Create table #t_reconcile( t_lot_number int not null, t_A ...

Filter one datasource column with multiple values
I've done some poking around, but didn't see an answer on this. I have a GridDataSource that I want to filter when the page loads. But I want to filter a column by multiple values, like using a "contains" or an "in". The column is an integer value. I tried this: protected void GridDataSource_Selecting(object sender, LinqDataSourceSelectEventArgs e) { if (someCondition) { using (MyDBContext db = new MyDBContext ()) { e.Result = db.Employees.Where(emp => _currentUser.ShiftIds.Contains(emp.ShiftID)); } ...

one textbox to search multiple columns in a sql databse?
hi i have a search box, of which it is required to search multiple columns in a database, how would i go about doing this? thanks in advance! Hi, Do you want to search in a singale table or multiple table in the database? Elaboarte it a bit..so that we can help you out.CheersRam MCP there are 3 columns all in the one table. i'm wanting the one search box to be able to search through all 3 columns, currently i only have it searching through one of the columns. Hi, FrankBollard: You can have a look at this great user control. www.codeproject.com/aspnet/GridViewSearch.aspBe...

Display Multiple Columns into One Column
My first ASP.NET/SQL project. I'm creating an Asset Management DB. I wish to view the Asset number, the full name of the user it's assigned to and the Make and Model of each record in the DB. However assets are split into different categories e.g. monitors, PCs, Preinters etc. and they are all in different tables. The SQL below displays the asset number, Name of person assigned and the model of the asset. SELECT Hardware.AssetNo, [User].FullName, MonitorModel.Model, PCModel.Model AS Expr1, PrinterModel.Model AS Expr2 FROM Hardware INNER JOIN [User] ON Hardware.UserID = [User].User...

Split One Column into multiple columns
Hi all, I have a requirement like this  , I have Address Column.It is containing data like Mr. K KK Tank Guntur Jal Bhavan, Univercity Road, Rajkot 9843563469 I have to split this into 3 more columns like(Address1,name,phoneno)-- Means i have 4 columns including Address Column.(Address,Address1,name,phoneno)   Example: Address:Rajkot Address1:Univercity Road Name:Mr. K KK Tank Guntur Jal Bhavan PhoneNO:9843563469   How can i acheive this one with out data lose in Address Column. Thanks in advance.      G.JaganMohanRaoMumbaiIndia If t...

strore multiple value in single column in database in comma separated format?????
 i hav one listbox where i user select multiple values and send them to database.....i wan to knw how to save those vlaues in single column in SQL EXPRESS in comma separated format????and can some body give me a query  to search any value among those  value????example..ASP.net,JAVA,SQL SERVER, is stored in single column in comma separated format then how to search asp.net in that column????or if i make master table for ASP.NET,java etc and try to save 1 against asp.net and 2 agianst java then how to save and how to search????? Plzz help..its urgent...  Abhi ht...

Multiple values into one column
Can anyone tell me how to put more than one value of the same type into a column? Here's my situation:I am making a patient list for a class. In it, I have a list of patients with corresponding dates of operation and sicknesses. However, sometimes a patient may have more than one sickness or date of operation. How can I make my application deal with this uncertainty? Thanks in advance for any help. This is a classic 1-to-many scenerio that requires something called normlization.  This simply means that you need to create a separate table to hold the "many" values which is then associa...

Alter Multiple Columns in SQL
This does not work, incorrect syntax... Please help: ALTER TABLE dbo.classifieds_HotelAds ALTER COLUMN ( HasValetParking varchar(1) NULL, HasContinentalBreakfast varchar(1) NULL, HasInRoomMovies varchar(1) NULL, HasSauna varchar(1) NULL, HasWhirlpool varchar(1) NULL, HasVoiceMail varchar(1) NULL, Has24HourSecurity varchar(1) NULL, HasParkingGarage varchar(1) NULL, HasElectronicRoomKeys varchar(1) NULL, HasCoffeeTeaMaker varchar(1) NULL, HasSafe varchar(1) NULL, HasVideoCheckOut varchar(1) NULL, HasRestrictedAccess varchar(1) NULL, HasInteriorRoomEntrance varchar(1) NULL...

multiple values in one column
hi, i have a gridview display a list of available courses, including dates, prices, places left etc which is populated from a database table called courses. One column in the gridview is also meant to display instructors, which are in their own table. i have a table called instructors2courses linking courses with multiple instructors. how do i display a list of the instructors for a course in only one column in the gridview? i know i can create datasets and relations, but then my code would have to create its own HTML wouldnt it? maybe i could use a repeater? thanks!  if you...

insert multiple values from one table into one column from another table?
Hi, I'm attempting to create an insert statement that gets the values from multiple columns and insert them into one column from another table, is there a simple solution to do this?Here is something similar to what i'm wanting done, just it's not the correct way to do it, i want value1, value2 and value3 from one table to be combined and put into the value1 column of another table, what am i doing wrong? INSERT INTO tablename2 (value1 + value2 + value3)SELECT value1FROM tablename1 thanks in advance! INSERT INTO tablename2 (SELECT val1 + val2 + val3 FROM tabl...

counting multiple values from the same column and grouping by a another column
This is a report I'm trying to build in SQL Reporting Services. I can do it in a hacky way adding two data sets and showing two tables, but I'm sure there is a better way. TheTable Order# Customer Status STATUS has valid values of PROCESSED and INPROGRESS The query I'm trying to build is Count of Processed and INProgress orders for a given Customer. I can get them one at a time with something like this in two different datasets and showing two tables, but how do I achieve the same in one query? Select Customer, Count (*) As Status1 FROM TheTable Where (Sta...