Professional Web Applications Themes

Why does 'SELECT * FROM countries' truncate characters and SELECT country FROM countries does not ? - MySQL

Hi, Why does 'SELECT * FROM countries' truncate characters and SELECT country FROM countries does not ? mysql> SELECT * FROM countries; +-------------+-----------+ | country | capital | +-------------+-----------+ |ghanistan | Kabul |lbania | Tirane |Algeria | Algiers mysql> SELECT country FROM countries; +-------------+ | country | +-------------+ | Afghanistan | | Albania | | Algeria | +-------------+ 3 rows in set (0.00 sec) c:\countries.csv Afghanistan, Kabul Albania, Tirane Algeria, Algiers mysql> LOAD DATA LOCAL INFILE 'c:\countries.csv' INTO TABLE countries -> FIELDS TERMINATED BY ','; Query OK, 3 rows affected (0.00 sec) Records: 3 Deleted: 0 Skipped: 0 Warnings: 0 ...

  1. #1

    Default Why does 'SELECT * FROM countries' truncate characters and SELECT country FROM countries does not ?

    Hi,

    Why does 'SELECT * FROM countries' truncate characters and SELECT country
    FROM countries does not ?


    mysql> SELECT * FROM countries;
    +-------------+-----------+
    | country | capital |
    +-------------+-----------+
    |ghanistan | Kabul
    |lbania | Tirane
    |Algeria | Algiers


    mysql> SELECT country FROM countries;
    +-------------+
    | country |
    +-------------+
    | Afghanistan |
    | Albania |
    | Algeria |
    +-------------+
    3 rows in set (0.00 sec)




    c:\countries.csv

    Afghanistan, Kabul
    Albania, Tirane
    Algeria, Algiers

    mysql> LOAD DATA LOCAL INFILE 'c:\countries.csv' INTO TABLE countries
    -> FIELDS TERMINATED BY ',';
    Query OK, 3 rows affected (0.00 sec)
    Records: 3 Deleted: 0 Skipped: 0 Warnings: 0

    countries TABLE
    country VARCHAR(30) NOT NULL
    capital VARCHAR(50) NOT NULL


    PRS Guest

  2. #2

    Default Re: Why does 'SELECT * FROM countries' truncate characters and SELECTcountry FROM countries does not ?

    PRS wrote:
    > Why does 'SELECT * FROM countries' truncate characters and SELECT country
    > FROM countries does not ?
    >
    >
    > mysql> SELECT * FROM countries;
    > +-------------+-----------+
    > | country | capital |
    > +-------------+-----------+
    > |ghanistan | Kabul
    > |lbania | Tirane
    > |Algeria | Algiers
    'country' isn't truncated. 'capital' ends with a '\r' (carriage return)
    character.
    > mysql> LOAD DATA LOCAL INFILE 'c:\countries.csv' INTO TABLE countries
    > -> FIELDS TERMINATED BY ',';
    Add 'LINES TERMINATED BY' (see mysql docs)

    where you put '\r\n' when the file was created on a windows platform, or
    '\n' when created on a unix platform.

    Probably the file was created on a windows platform and read into a unix
    platform, so that the \r that windows adds to the end of the file is
    still in the 'capital' field.

    Bart
    Bart Friederichs Guest

Similar Threads

  1. free DB with countries/cities??
    By Job in forum MySQL
    Replies: 4
    Last Post: October 9th, 08:01 PM
  2. flash not working in few countries
    By bijaymbt in forum Macromedia Flash Player
    Replies: 1
    Last Post: May 6th, 09:31 PM
  3. Countries Database - a little OT
    By Chris Kennedy in forum ASP Database
    Replies: 2
    Last Post: March 4th, 05:00 PM
  4. Countries and TimeZones
    By Martin Brunner in forum PHP Development
    Replies: 4
    Last Post: September 30th, 01:01 PM
  5. countries,states and cities
    By Augusto cesar castoldi in forum PHP Development
    Replies: 2
    Last Post: September 29th, 10:05 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