# Miscellaneous > SQL Scripts >  Joining - Problem

## dajm

I have 2 tables (cars, equipment). They have the relation 1:n on the car-ID.
My following problem is:

For a csv-Export i need to concat these tables again by using the car-id is primary key.

Additionally, I need to concat all equipments from one car into one field.
Here an example:

1. data row table "Car":

Car-id: '1234567'
otherfield1: 'xxx'
otherfield2: 'yyy'

Table "Equipment":

Car-ID        equipment   price (no VAT)
1234567       x           100
1234567       y           200
1234568       x           300

There is no fix limitation for the number of equipment per car.
The CSV shall look like the following:


1234567;x,y;100,200

I have no idea.
Can anybody help ? Thx.
 :Confused:

----------


## skhanal

It's not straight forward. You will have to write a user defined function to take car id as parameter and return comma delimited string with all the equipment.

Then use select on car

select carid+','+fn_getequipment(carid)
from car

----------

