| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

10-07-09, 11:13
|
|
Registered User
|
|
Join Date: Oct 2009
Posts: 6
|
|
|
Help with adding products to database
|
|
I am a newbie to sql so here is what I am trying to do, can somebody please help me.
I have an excel spreadsheet with 4 columns of products as listed below
1) Product Name
2) Description
3) Price
4) Link
I am using myphpadmin and I created 4 tables with the names listed above. I converted the excel file to csv and then I imported it to my database but I cannot make it to show in the right tables. Can someone please help me by telling how to do it from scratch. I do not know if when I created the tables if I used the right format for each table. If this was your project how would you create the tables and how would you upload the files (step by step instructions would be very helpful). Thank you in advance.
|
|

10-07-09, 14:15
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
|
|
there should be only one table, not four
CREATE TABLE products
( Name VARCHAR(55)
, Description VARCHAR(55)
, Price DECIMAL(7,2)
, Link VARCHAR(55)
);
then look up the LOAD DATA INFILE command to load your csv directly into this table
|
|

10-07-09, 15:07
|
|
Registered User
|
|
Join Date: Oct 2009
Posts: 6
|
|
|
|
I want to thank you for taking the time to help me. I went ahead and created the tables but when I try to import the csv file into my database, all the information is only copied into the Name field. The other tables all have NULL on them. I tried every possible way to import it but I cannot import each column to the tables that I created. This is exactly what I am doing to import the csv file.
1) I click on the IMPORT tab in myphpadmin
2) I locate the file in my hard drive and then I choose CSV USING LOAD DATA option. I leave the OPTION field the way they are because I do not know what they are for and then I press GO.
3) I get a message that it was successful but when I check my tables, only the NAME table has all the data entered on it and the other tables have NULL on them.
Please help. Thanks in advance.
|
Last edited by 915855; 10-07-09 at 15:11.
|

10-07-09, 17:35
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
|
|
there should be only one table, not four
|
|

10-07-09, 17:45
|
|
Registered User
|
|
Join Date: Oct 2009
Posts: 6
|
|
Sorry, there is one table and it has 4 fields. Can you please tell me what I am doing wrong when uploading the file.Thanks
|
|

10-07-09, 18:10
|
|
vaguely human
|
|
Join Date: Jun 2007
Location: London
Posts: 2,519
|
|
Assuming your using data load command then you need to look at the field separator clause.
|
|

10-07-09, 18:23
|
|
Registered User
|
|
Join Date: Oct 2009
Posts: 6
|
|
Can you tell me how I would do that.Thanks
|
|

10-07-09, 20:12
|
|
vaguely human
|
|
Join Date: Jun 2007
Location: London
Posts: 2,519
|
|
You'll need to give us what you initially used to load the data plus the first few lines of the data. It would help if we had the table definition to.
|
|

10-07-09, 21:24
|
|
Registered User
|
|
Join Date: Oct 2009
Posts: 6
|
|
I am a newbie and you totally lost me with your question but I will try to answer it. I created the data in excel and saved it as CSV. The data has 4 columns as follows:
Column 1 = Name
Column 2 = Description
Column 3 = Price
Column 4 = Link
The table definition is the same as the one given to me by r937 which is:
CREATE TABLE products
( Name VARCHAR(55)
, Description VARCHAR(55)
, Price DECIMAL(7,2)
, Link VARCHAR(55)
);
Any help I will greatly appreciate it. Thanks.
|
|

10-08-09, 04:02
|
|
vaguely human
|
|
Join Date: Jun 2007
Location: London
Posts: 2,519
|
|
How did you import the csv file into the database?
Is there an option to set the field separator to a comma?
|
|

10-08-09, 08:24
|
|
Registered User
|
|
Join Date: Oct 2009
Posts: 6
|
|
I did not set an option. Can you please tell me step by step instructions on how to fill out these fields. Thanks.
|
|

10-12-09, 12:06
|
|
Registered User
|
|
Join Date: Oct 2009
Posts: 8
|
|
|
Import csv file using phpMyAdmin
-Create the database first.
-Click on the database name.
-Click the import tab.
-Browse and find the csv file you want to import- using r937 file format
-Click go.
This may help.
|
|

10-12-09, 13:41
|
|
Registered User
|
|
Join Date: Oct 2009
Posts: 8
|
|
|
Import file to database using myphpadmin
CREATE TABLE products
( Name VARCHAR(55)
, Description VARCHAR(55)
, Price DECIMAL(7,2)
, Link VARCHAR(55)
);
INSERT INTO `products`(`Name`,`Description`,`Price`,`Link`) VALUES ('Corn','Yellow Corn','$5.00','www.light.com'),
('Pepper','Hot Pepper','10.00','www.whatever.com');
Additional info.
|
|

10-12-09, 23:29
|
|
Registered User
|
|
Join Date: Oct 2009
Posts: 1
|
|
I agree this is exactly for the csv file:
1) I click on the IMPORT tab in myphpadmin
2) I locate the file in my hard drive and then I choose CSV USING LOAD DATA option. I leave the OPTION field the way they are because I do not know what they are for and then I press GO.
3) I get a message that it was successful.
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|