473,473 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Combining multiple columns into one row in one field

I have a table, tblManinstructions with fields Code & InstructionID, one
Code can have many InstructionID. I also have tblinstructions (fields
instructionID & instruction). What I want to do is create a table with the
fields Code and Instruction - a combination of all instructions from the
instruction IDs in tblManinstructions). E.g. Code 1234 currently has 4
fields in tblManinstructions, instructionIDs 28, 43 & 76. The new table I
want to create will have one row with the instructions of Ids 28,43 & 76 in
one field, separated by commas. Can anyone help?

thanks
Nov 13 '05 #1
2 3387
I understand you have multiple fields with the same meaning (InstructionID)
in the main record. If I am wrong, please clarify. If I am correct in my
understanding, that is not a good idea because it will cause problems for
you, sooner or later.

For example, sometime , you'll have a need to join tblMaininstructions and
tblInstructions... for a report, perhaps. If you had a foreign key to
tblMaininstructions in tblInstructins (if it is one to many) or a junction
table with foreign keys to both (if many to many), that would be easy. And,
when that comes up, expect to hear the same again from many sources.

You omitted an important part, which is the names of the multiple
InstructionID fields in tblMaininstructions. For brevity, I will use ID1,
ID2, ID3, and ID$ for this example:

ID1 & (", "+ ID2) & (", "+ ID3) & (", "+ ID4)

should give you the result that you want, presuming that if there are any
IDs, there will be an ID1. The + operator for concatenation results in a
Null if either of the operands is Null; the & operator treats Null as if it
were an empty string, so the result is not Null.

Larry Linson
Microsoft Access MVP

"Will" <Wi************@hotmail.com> wrote in message
news:3i************@individual.net...
I have a table, tblManinstructions with fields Code & InstructionID, one
Code can have many InstructionID. I also have tblinstructions (fields
instructionID & instruction). What I want to do is create a table with the
fields Code and Instruction - a combination of all instructions from the
instruction IDs in tblManinstructions). E.g. Code 1234 currently has 4
fields in tblManinstructions, instructionIDs 28, 43 & 76. The new table I
want to create will have one row with the instructions of Ids 28,43 & 76 in
one field, separated by commas. Can anyone help?

thanks

Nov 13 '05 #2
Firstly, thanks for your help,
tblManInstructions is my link table and has two fields - ProductCode and
InstructionID. These fields are both foreign keys, linking to
tblInstructions & tblProducts. I'm not sure whether this is right, but it
is how I inherited it! I am trying to convert it to a table where the
relationship is one product to one instruction. The multiple InstructionID
fields in tblManinstructions all have the same name - InstructionID - there
are just multiple records for each Instruction. I am trying to join columns
together rather than rows.

"Larry Linson" <bo*****@localhost.not> wrote in message
news:IQdye.326$Gv3.318@trnddc02...
I understand you have multiple fields with the same meaning (InstructionID)
in the main record. If I am wrong, please clarify. If I am correct in my
understanding, that is not a good idea because it will cause problems for
you, sooner or later.

For example, sometime , you'll have a need to join tblMaininstructions and
tblInstructions... for a report, perhaps. If you had a foreign key to
tblMaininstructions in tblInstructins (if it is one to many) or a junction
table with foreign keys to both (if many to many), that would be easy.
And, when that comes up, expect to hear the same again from many sources.

You omitted an important part, which is the names of the multiple
InstructionID fields in tblMaininstructions. For brevity, I will use ID1,
ID2, ID3, and ID$ for this example:

ID1 & (", "+ ID2) & (", "+ ID3) & (", "+ ID4)

should give you the result that you want, presuming that if there are any
IDs, there will be an ID1. The + operator for concatenation results in a
Null if either of the operands is Null; the & operator treats Null as if
it were an empty string, so the result is not Null.

Larry Linson
Microsoft Access MVP

"Will" <Wi************@hotmail.com> wrote in message
news:3i************@individual.net...
I have a table, tblManinstructions with fields Code & InstructionID, one
Code can have many InstructionID. I also have tblinstructions (fields
instructionID & instruction). What I want to do is create a table with
the fields Code and Instruction - a combination of all instructions from
the instruction IDs in tblManinstructions). E.g. Code 1234 currently has
4 fields in tblManinstructions, instructionIDs 28, 43 & 76. The new table
I want to create will have one row with the instructions of Ids 28,43 & 76
in one field, separated by commas. Can anyone help?

thanks


Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Dennis | last post by:
In CSS3 it looks like we'll have multiple column flowing of text (newspaper style) in which the number of columns can be determined automatically given the available horizontal space....
16
by: lostinspace | last post by:
Is it possible? TIA
7
by: Billy Jacobs | last post by:
I am using a datagrid to display some data. I need to create 2 header rows for this grid with columns of varying spans. In html it would be the following. <Table> <tr> <td colspan=8>Official...
3
by: Jane | last post by:
Hi, If anyone could help me with this, I greatly appreciate it. I would like to know how I can display data from a db in multiple columns rather than have it displayed in 1 column per recordset....
2
by: Beacher | last post by:
Morning all, I have a listbox, and I want to populate it with a table.. right now the listbox's rowsource is set to SELECT * FROM tblCondition but it only grabs the first field from the table and...
3
by: Regnab | last post by:
I have four columns in one table. I want to add all the records in each of these columns into 1 column in another table. Any ideas??
2
by: ray well | last post by:
i need to display 2 columns of data in a list box. how would i set this up IN CODE. say my table is tblNames, and i have 2 fields, FirstName, LastName, and want the data to show up in 2...
3
by: Will | last post by:
Can someone help with code to delete multiple columns from an excel spreadsheet? I know which columns I need to delete. The code below will delete a single column but I'm not sure how to delete...
6
by: Jeremy Goodman | last post by:
Access 2007; Merging records containing multivalue drop down lists. I have a database showing legislation information divided by State/territory. The database needs to be able to show the info...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.