Professional Web Applications Themes

LOAD DATA INFILE - MySQL

Removed by Administrator...

  1. Moderated Post

    Default LOAD DATA INFILE

    Removed by Administrator
    Luca Guest
    Moderated Post

  2. Moderated Post

    Default Re: LOAD DATA INFILE

    Removed by Administrator
    Luca Guest
    Moderated Post

  3. #3

    Default LOAD DATA INFILE

    Hello folks,

    Is it possible to update a column using LOAD DATA INFILE, So the
    following is an example:

    LOAD DATA LOCAL INFILE 'c:/test.txt'
    INTO TABLE test
    FIELDS TERMINATED BY ','
    LINES TERMINATED BY '\n'
    (lname, fname, zip);

    Results:

    id | fname | lname | zip
    1 | kurt | russell | 45678
    2 | worth | tim | 45687
    3 | ridd | sherly | 45698

    Now, I would like to load a file into the test table to replace only
    the zip column with the following:

    LOAD DATA LOCAL INFILE 'c:/test.txt'
    REPLACE INTO TABLE test
    FIELDS TERMINATED BY ','
    LINES TERMINATED BY '\n'
    (zip);

    But the above query removes the current data and sets only the zip and
    removes id, fname, lname. I would like it to update the zip column
    only. Is it possible?

    Thank you,

    Dan

    dcruzjr@gmail.com Guest

  4. #4

    Default Re: LOAD DATA INFILE

    == Quote from dcruzjr ( com)'s article 

    how about this:

    LOAD DATA LOCAL INFILE 'c:/test.txt'
    REPLACE INTO TABLE test (id, dummy, fname, dummy, lname, dummy, zip)
    FIELDS TERMINATED BY ','
    LINES TERMINATED BY '\n';

    --
    POST BY: lark with PHP News Reader
    lark Guest

  5. #5

    Default Re: LOAD DATA INFILE

    On 11 Jul, 13:22, lark <net> wrote: 
    >
    > how about this:
    >
    > LOAD DATA LOCAL INFILE 'c:/test.txt'
    > REPLACE INTO TABLE test (id, dummy, fname, dummy, lname, dummy, zip)
    > FIELDS TERMINATED BY ','
    > LINES TERMINATED BY '\n';
    >
    > --
    > POST BY: lark with PHP News Reader- Hide quoted text -
    >
    > - Show quoted text -[/ref]

    So, he asks to replace only the zip (I'm assuming that the text file
    contains only the zip and the id, which I would hope was a primary key
    - but his statement about the id being removed sounds a bit wierd).
    Anyway, you come up with a solution that instead of just replacing the
    zip, replaces all the other fields too.

    Nice one Lark.

    Captain Guest

Similar Threads

  1. LOAD DATA INFILE problem
    By howachen@gmail.com in forum MySQL
    Replies: 3
    Last Post: June 10th, 05:56 PM
  2. Complex LOAD DATA INFILE
    By stefaan.lhermitte@agr.kuleuven.ac.be in forum MySQL
    Replies: 6
    Last Post: May 18th, 06:34 PM
  3. Load Data Infile question
    By bradfordh@gmail.com in forum MySQL
    Replies: 3
    Last Post: March 23rd, 04:53 AM
  4. Replies: 0
    Last Post: January 17th, 07:47 PM
  5. help : LOAD DATA LOCAL INFILE
    By Dave in forum PHP Development
    Replies: 3
    Last Post: October 5th, 12:22 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139