473,325 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Concatenating multiple row values to one row

ronnil
134 Expert 100+
My database looks like

t1
id
label

t2
id
attr_nam
attr_val

Now what i want to do, is to select all rows from t2 and join them with the single row in t1 so the result will look like this
-----------------------------------------------------------------------
| id | label | attr_nam1 | attr_val1 | attr_nam2 | attr_val2 |
-----------------------------------------------------------------------
etc where attr_nam1 and attr_nam2 is placeholder for specific variable names.

I was thinking of using somekind of a subquery, but since the number of attributes varies, I don't really know how that should be implemented.

Anyone got some good advise?

(ofcourse i could do this with 2 queries and a simple iteration, but if it could be managed in a SQL statement that would be even greater ;) )
Jun 12 '07 #1
2 1452
Atli
5,058 Expert 4TB
I'm not sure thats possible, well not in any reasonable way anyways.
Im not sure why you'd want the data in that format, its kind of a step backward from the form it's in on the database, unless your gona stream it somwhere.

Anyways, I would use some API to do something like this. SQL is ment to return data in tables, not streams.
Jun 18 '07 #2
zottty
27
No, unfortunately you can't do this in SQL
Jun 19 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Doug Shokes | last post by:
All, Given multiple records with identical values in all fields except a single varchar field, is there an efficient query that will group the records into a single record and concatenate the...
4
by: Juan | last post by:
Does any one know if there are reported bugs when concatenating strings? When debugging each variable has the correct value but when I try to concatenate them some values are missing (I can´t see...
1
by: Ani | last post by:
I have a questionaire page , which basically has questions with multiple choice answers. I need to accomplish paging on this and there are few questions that are gender specific. According the...
3
by: bhaalsen | last post by:
Hi there! I got a slight problem with a web application, its supposed to several entries for a certain ID, and display them as one string. Example: ID | Name ------------- 1 | Jack
6
by: david.buckingham | last post by:
I have a customer who has recently migrated their SQL server to a new server. In doing so, a portion of a stored procedure has stopped working. The code snippet is below: declare @Prefixes...
11
by: Girish Sahani | last post by:
I wrote the following code to concatenate every 2 keys of a dictionary and their corresponding values. e.g if i have tiDict1 = tiDict1 = {'a':,'b':} i should get tiDict2={'ab':} and similarly for...
4
by: lindiwemaduna | last post by:
I want to concatenate values of two text boxes into one string but these should be separated by a space in the database table. i have tried all the following but twas not successful: Dim fullName...
3
by: meter_man | last post by:
Is there a way to bring historical data into one field? I have activities A1, A2, A3 ,etc in a history table. I need to check for the presence of that data and bring it back if it exists for a...
3
by: TheCoder | last post by:
Why does this work: It seems that we're concatenating two literals: std::cout << greeting + name + " Hello " + "There" << std::endl; but if you remove (greeting + name +), it doesn't work ?
5
by: yogarajan | last post by:
hi friends i have 3 table table 1 - > question master field qid (primary key), question (nvarchar) type (1- single answer, 2-multiple answer) qid - question - type 1 - 5+3 - 1...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.