Results 1 to 3 of 3
  1. #1
    Join Date
    May 2012
    Posts
    17

    Unanswered: 'Import' data from a text field

    Sorry if the title is vague but here it goes:
    I have in a text field data like this: productname, space, productnbr. Expl:

    XXXXXXXXXX...1234567894785
    XXXXXXXXXX...1234567894785
    XXXXXXXXXX...1234567894785
    XXXXXXXXXX...1234567894785
    XXXXXXXXXX...1234567894785
    etc etc etc
    XXXXXXXXXX...1234567894785

    where the XXXXXXXXXX is productname, the 3 dots are 3 spaces, and the nbr a 13 digit productnbr. Each product and its serial nbr are on a separate line as shown above.
    Productnames already exist in another table (Product table) that has among other fields: productname, productnbr.

    I am looking for a way to 'import' the product nbrs from the Text field to the Product table. If the original data were in 2 fields, a simple Update statement would do the trick.

  2. #2
    Join Date
    Oct 2012
    Posts
    5
    With MySQL command: load data infile 'd:/test.txt' into table nmg fields terminated by ',' lines terminated by '\r\n';

    The detailed command is:
    LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name.txt' [REPLACE | IGNORE] INTO TABLE tbl_name [FIELDS [TERMINATED BY 'string'] [[OPTIONALLY] ENCLOSED BY 'char'] [ESCAPED BY 'char' ] ] [LINES [STARTING BY 'string'] [TERMINATED BY 'string'] ] [IGNORE number LINES] [(col_name_or_user_var,...)] [SET col_name = expr,...)]

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    except that the columns are terminated by 3 spaces
    ..you will wither need to type

    With MySQL command: load data infile 'd:/test.txt' into table nmg fields terminated by ' ' lines terminated by '\r\n';

    or edit the fiel to repalce the spaces with a comma
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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