vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 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 |