Results 1 to 2 of 2

Thread: Joining - Problem

  1. #1
    Join Date
    Mar 2004

    Joining - Problem

    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:


    I have no idea.
    Can anybody help ? Thx.

  2. #2
    Join Date
    Nov 2002
    New Jersey, USA
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts