Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

not working as expected 2

Status
Not open for further replies.

TipGiver

Programmer
Sep 1, 2005
1,863
Hi,
i'm new to SQL and generally just started 'dealing' with databases.
All i need is to insert data from the disk to a table.

The Text File:

30434 menios
30567 dimitris
30666 skatas
30123 testing


SQL syntax:

mysql> load data local infile 'c:\\sub.txt' into table m;
Query OK, 4 rows affected (0.00 sec)
Records: 4 Deleted: 0 Skipped: 0 Warnings: 0

mysql> select * from m;
+-------+-----------+
| am | name |
+-------+-----------+
|434 | menios
|30567 | dimitris
|666 | skatas
| 30123 | testing |
+-------+-----------+
4 rows in set (0.00 sec)

Why is that happening?
- my PC: MySQL last version (5. ..), win32
- It works fine under linux!

'Describe' of m table
mysql> describe m
-> ;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| am | int(11) | YES | | NULL | |
| name | varchar(10) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)


Tnx
 
Danomac, thanks, you are right.

BUT
what i don't understand is: I use my first way, like: "load data.... m;". The text file has "30434", and with a select it shows |434.
The data are saved correctly but are not displayed right. I tested it using: select * from m where am=30434.
What is displayed, is: | 30434 | menios |
 
I think the answer is in my posting from 3 Nov 05 9:47.
[ponder]
 
".. already has been displayed, will be overwritten.."

Yes! ->*
 
The TRIM() idea was to update the data to remove the offending \n \r \l whatever from the inserted data before displaying it, thereby fixing the displayed data issue.

Still, good job all, the final solution seems to have been achieved.


______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top