Results 1 to 3 of 3

Thread: Simple SQL insert

  1. #1
    Join Date
    Oct 2002
    Posts
    1

    Simple SQL insert

    Hi there, i'm not that good with SQL scripts and any help would
    be appreciated.

    I have two tables with a field in each, containing string data,
    I want to merge the data from these two fields, into a single
    field within another table in the database, i know its probably
    pretty simple and i'm being lazy asking you lot but i'm pretty
    busy and havn't got time.

    thanks for any help

  2. #2
    Join Date
    Oct 2002
    Location
    Boston
    Posts
    5

    Inserts

    Your description is not complete -- or the problem is not solvable. Essentially, you need to join your tables together. Since each contains a single text column, there does not seem room for a key - unless you left that information out. Repost showing the structure of both tables in their entirety, including key fields. If you are relying on the "order" of data in the database, it will depend on your dbms. If you have Oracle or have Sybase or MSSQL with a clustered index, your "order" is already lost (there may be a way to recover it in MSSQL if you have not clustered, but the level of effort required would be greater than reentering the data unless you have thousands of records).

  3. #3
    Join Date
    Nov 2002
    Posts
    8
    Assuming your source tables are linked:

    Table a = source one
    Table b = source two
    Table c = destination

    you could use a query something like this. You will have to use convert if the fields are a number type.

    insert into c
    select a.id, a.source_one + ' ' + b.source two
    from a inner join b on a.id = b.id

Posting Permissions

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