Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    MYSQL




How To Import Data Into Existing Rows Of A Table?


I have moved 665 records off of Filemaker into mysql-4.0.18. I had a
great deal of trouble exporting a text field, possibly because it had
control characters that interferred with my field delimiter (also it
was from a Mac, and I'm new at this.)

So I have a table called invoices and another table called tasks, that
has only an invoice number and the work billed on that invoice number.
To see the work billed along with the other invoice data I have to do
a join, and this works but is clumsy for me. Since tasks.work is a
text field of 'infinite' variety I don't see the sense of keeping it
in a separate table like I would with clients' info; it belongs *in*
the invoice table, not just with it.

Is it possible to import this text data into a field in the invoice
table? I've messed around with this but it always appends the data as
new records. Perhaps I was doing an insert back then. Is the answer
something like 'load data infile 'workdone.csv' into invoices
(workdone);'

The invoices table was filled in a certain order (by invoice number)
and the workdone.csv was exported in the same order, so each invoice
row should get its correct text.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Import Data Into Existing Rows Of A Table?
I have moved 665 records off of Filemaker into mysql-4.0.18. I had a
great deal of trouble exporting a text field, possibly because it had
control characters that interferred with my field delimiter (also it
was from a Mac, and I'm new at this.)

So I have a table called invoices and another table called tasks, that
has only an invoice number and the work billed on that invoice number.
To see the work billed along with the other invoice data I have to do
a join, and this works but is clumsy for me. Since tasks.work is a
text field of 'infinite' variety I don't see the sense of keeping it
in a separate table like I would with clients' info; it belongs *in*
the invoice table, not just with it.

Is it possible to import this text data into a field in the invoice
table? I've messed around with this but it always appends the data as
new records. Perhaps I was doing an insert back then. Is the answer
something like 'load data infile 'workdone.csv' into invoices
(workdone);'

The invoices table was filled in a certain order (by invoice number)
and the workdone.csv was exported in the same order, so each invoice
row should get its correct text.

Is this a good thing, or am I thinking too 'flat-file-ish'?

Import Data Via Ssh Into An Existing Table
I want to import data from several .sql files into an existing database, into one table.

I tried using the following command:
mysql -e [sqlfile] [db_name]

But the problem was when I imported the next file, it would overwrite the previous imported data.

Could anyone let me know how to do this correctly, please?

Import Additional Field Data To Existing Table
I've got my data all set-up in a mysql table and all functioning well.

We have decided that we need some additional bits of data for each record and we have that data in a csv file. We've created the fields in the mysql table.

In the csv file, I have the userid (to match that in the current sql table) and the additional data with the column names in the csv file matching exactly the new fields in the sql table.

The additional fields in the original sql table are empty, so we can just simply write-over these fields with the data from the csv file.

But...we are having problems with the import using the MySql administration tool on our server.

If I select a csv file upload, I get a number of fields is not same error
If I use csv load data upload, it just overwrites the first few lines of current data and doesn't put the new data in the correct fields.

Can anybody help, please? If csv load data is the correct format to use, what do I put in the import tool for these variables (given that I have a standard csv file that has been created using excel)

Replace table data with file (yes/no default is no)
Ignore duplicate rows (yes/no - default is no)
Fields terminated by(default is
Fields enclosed by(default is ")
Fields escaped by(default is )
Lines terminated by(default is auto)
Column names (default is blank)
Use LOCAL keyword (yes/no - default is yes)



Inserting 100 Rows Of Data Into An Existing Table
I want to import 100 rows of data from an Excel spreadsheet into an existing MySQL table. Both the spreadsheet table, and the MySQL table have the same exact format & headers.

In MySQl Query Browser, I can locate only the Edit function, which seems to only allow me to type in the data line by line. Can I import the data in MySQL Query Browser, or do I need another product? And if I can import, how do I do this?

Table Joins On Existing/Non-Existing Data
I have a question that involves a joining tables on potentially non-existing data, but we will know the expected values whether they exist or not.

Say we're keeping statistics on any given number of sports for attendances over weekly time periods. There's two tables to hold data.

------------------------------
TABLE: StatisticTypes
id
name
------------------------------
TABLE: Statistics
id
statisticTypeId
value
date
------------------------------

Then, say, we have three entries in the StatisticTypes table for types of sports we're keeping data on...

SQL*plus Inserting New Row With Values = To Existing Rows Data
I am trying to insert a new employee into an empolyee table and get some of the values (namely phone no.) to be the same as what another employee currently has. This new employee is replacing the old employee, but i have to keep the old employee alive in the db as other data is reliant on its existance.

I was wondering how do i insert the new employee asking the, VALUE ('etc', 'etc',) line, to assign a value to certain fields equal to the value contained in other employee rows.

Add Multiple Rows To An Existing Table?
I have a table named manufacturers, it has one row in right now. I want to upload all of my manufacturers into the table. Is there a way to add multiple rows to the table at the same time? If not, what is a quick way to get about 1,000 manufacturers uploaded into a table?

Import A Csv To Update Only Certain Rows Of Data?
I have an existing mysql table and a csv. I want to import the csv into the table, but it is at a different sort order. There are too many records to sort my csv by hand to match. There is a common 'cd_code' field that both have.

Is it possible to import a csv to the table so that each row of the csv is inserted in the correct row of the table, based on the common 'cd_code' field?

For example, if I sorted by cd_code asc, it would match the csv, but how to I import the csv into a particular sort?

Append Existing Data In A Table
I am working on an existing osCommerce store. There are over 200 products, each of which needs the associated image file name changed.

Rather than do this manually (any number of ways), I am unsure if there is a query I can run to save me lots of aggravation. What I would like to do is update whatever is in the field and change it to add the same 5 characters:

The Table is Products
The Field is products_image

Examples of existing data in this field are:

abcdef.jpg
ght.jpg
fire_777.jpg
oops.gif (the replacement image is a jpg)

The result I seek is:

abcdef_th.jpg
ght_th.jpg
fire_777_th.jpg
oops._th.jpg

Logic tells me to start at the end of the data, remove the last 4 characters (.jpg) and append 5, in this case: _th.jpg Could someone please give me a hand with this? I have spent many days redoing the image files and they are nearly ready to go into a live store.

Import Some Tables Into Another Pre-existing Database
I want to dump all but 6 tables of a database into a sql file.
THe below is all but those six tables (do I have to wrote out all the table names??)

mysqldump -u root -p --opt dbname --tables view_history top_level_feed tag_set pending_tag_set pending_tag pending_fact namespaced_predicate main_search_ns_pred main_search_keywd_pred main_search_keywd_ns_pred main_search_facets main_search_descr_pred main_search_descr_ns_pred job_watcher job_log_entry item_address_watcher feed_watcher feed_log_entry feed_group feed entity_type_sample_uri entity_type dw_user content_search_ns_pred content_search_facets colleague_search_ns_pred cnt_search_keywd_pred cnt_search_keywd_ns_pred cnt_search_descr_pred cnt_search_descr_ns_pred browse_trigger_pred browse_trigger_ns_pred browse_template browse_ns_pred auto_feed > dbNameTables917.sql

Then import them into another database that has all these tables already.
I want to overwrite these tables with new data from the dump.

Will the mysqldump utility work or should I use the mysqlimport dbname --lock-tables --delete /path/to/sqlfile.sql work?

Insert New Rows With Qty Values From Existing Rows
I am trying to make all my products unique in my db.
Lets say I have a row with an id, it also has all relevant details about the product and it has a quantity value of 4.
What I would like to do is take the entire row and duplicate it by the number of the quantity field.
This would result in the same product 4 times instead of one product with qty of 4.
Reason, I am going to serialise all the products so that they each have unique barcode from the id field.
I will encounter the reverse issue when running an insert statement for inputting new data, i.e. insert a new row for each item depending on its qty value??

Need To Import Data Into Table
Newbie here needing to import data into a dbase file table named "template". The file containing this data is "template.dump".

Trying To Import Data From Csv Into Table
I am trying to use mysqladmin import tool to import data into a table.

I used mysqladmin to export a table in a csv excel format. I then opened that spreadsheet and filled in a bunch of info.

Now I am trying to import that spreadsheet back into the table, but everytime I do I get an error: Invalid field count in CSV input on line 1.

I am using the import tool using csv as the format, and I am not changing any of the options...

MySQL - 4.1.18-standard-log
Protocol version: 10
phpMyAdmin - 2.8.0.2

Import Data From .txt File Into MySQL Table
i have text files which are generated daily and stored in a folder on the C: drive. I was wondering what would the mySQL command be to import that data into a mySQL table. The text file does not have a header with the field names so would i have to make that table first with the desired columns?? Also, does the file have to be in the databse directory or can it be anywhere on the machine??

View That Wont Return Existing Rows
i have a problem performing simple query over view. To make it short, so anyone
can recognize whether it is something im missing, this is the problem:

* i have created few levels of views (some of them are based on actual tables
and others are based on other created views or some mixed)
* lets say the name of the view i have problems with is "aView"
* when i perform "select * from aView" i get to see the view is correctly
populated
* when i add condition to the query above in some cases it returns ok results
but in others it returns 0 rows (which is wrong)

select * from aView where a=1, works fine
select * from aView where a=1 or b=2, works fine
select * from aVew where a=1 and b=3, returns 0 rows --- which is wrong(of
course not by itself but in my case there are rows with ok values) same goes with using only the condition on b column

a.) why wouldnt it fetch rows that are cleary in the view??
b.) is there any limitation on how high structure can we build using views

Add Additional Data To Existing Data In A Blob Field
I have a Blob field called "category" that we use to store different categories of job types that our users set up so they receive emails based off of the ones that they have picked. What I need to do is to add 4 new values to the beginning of each users "category" field.

I am not really sure how to do this except that I might need to use UPDATE to get it done. This is where it will get tricky, I need to check for the 4 values to see if they already have them and just add the oines that they don't have.

Here are the 4 values that I need to check for and add. Allied Health Care, Nursing, Rehab/Therapy, and Other/Pharmacy/Physicians. Here is what a current list of values would look like in the users table and the category column: Code:

Best Way To Get Data From Existing Database
what I'm trying to do is get data from an exhisting oracle database that is not looked after by myself but I have access to. What I want is for my MySql database to mirror the oracle one or update every 5mins or so. I have done a quick search but as I have only made simple databases before I'm not sure what to search for!

Edit Existing Data
I have just started to learn MySQL and this question might be silly. I have a MySQL table with user information. I want to edit this table in a website. I need to load existing data in a HTML form and then edit the fields and update them.
I searched the net but could not find anything .

Convert Existing Data
i am working on a project and i need to convert already existing data into the mysql date format. I was told for the project that the date format was necessary. my first question is what is the advantage of having the mysql date formate which goes like this yyyy-mm-dd. the format my data currently is in is like this mm/dd/yyyy. The second question is how to convert from mm/dd/yyyy to yyyy-mm-dd

Copying Column Names And Properties From An Existing Table To A New Table?
I've got a table with 42 columns, set to different types (string, datetime, date, integer). It has 8 million rows. I want to make a new table with the exact same columns, but with no data in it. Is there an easy way to do this without re-defining every column?

MySQL -- Editing Existing Data In A Row
I looked through ALTER table, and some tuts over at w3schools (my heros) but I can't seem to find a way to edit EXISTING data in an EXISTING row of a table.

Append Data To Existing Cells
I have an existing table. I need a way to append data in one of the columns. How do I append data in cells so I do not overwrite the existing data already in the cells in the column?

The fields in my table are `Source` , `Theswords` , `Topic` , `Subtopic` , `References`

The table name is ViewNew

The column I want to append is Theswords

Amending A Hierarchical Structure On Existing Data
I want to amend my table such that the following...

SELECT * FROM words;

+-------------+------+------------+
| root/parent | pos | word |
+-------------+------+------------+
| abandon | Verb | % |
| @ | @ | abandon |
| @ | @ | abandoned |
| @ | @ | abandoning |
| @ | @ | abandons |
| abbey | NoC | % |
| @ | @ | abbey |
| @ | @ | abbeys |
+-------------+------+------------+

would instead read...

SELECT * FROM words;

+--------------+------+------------+
| root/parent | pos | word |
+--------------+------+------------+
| NULL | Verb | abandon |
| abandon | Verb | abandoned |
| abandon | Verb | abandoning |
| abandon | Verb | abandons |
| NULL | NoC | abbey |
| abbey | NoC | abbeys |
+--------------+------+------------+

Thus dispensing with the need to rely on the table's natural order, but I'm a bit stuck as to how to go about this.
I'm happy to add a numerical key to the table if it makes this process easier.

In my mind (not an especially logical place) the logic is something like this:

if parent is not "@" set var_parent = parent and var_pos = pos
else set parent = var_parent and pos = var_pos
finally delete from words where word = "%"

But how do I turn that into something useful?

Duplicate Existing Database (innodb), Structure Only, Without Data
There's a database (innodb) named "test1". I want to create a new database with exact the same strcuture, but since there are many tables in this db i do not want to retype the whole commands.

I'm looking for a possibility to duplicate this database, any ideas / tools?

How Do I Generate Data Definition Statements For Existing Tables?
I cannot remember how to generate a create statement for an existing table. I tried searching the documentation but I don't think I'm searching for the right text.

I'd also like to know if there is a specific name for this task and what section it is under in the docs.

Migrating Data Into Existing Mysql Schema Tables
i understand how to migrate data into mysql and to use the migration tool to convert a database to a mysql schema, however, I'm not sure I understand how to migrate specific data tables/columns in the source file to specific tables/columns in the destination mysql tables (where the schema already exists and I'm simply importing data itself).

LOAD DATA INFILE To Import Data Exported From A MS Access Xp
I am trying to use LOAD DATA INFILE to import data exported from a MS Access Xp table. But all i get in the date field is 00:00:00, as Access exports DATE and TIME and MySQL seems to use just the TIME portion of this.

Is there any way to ahve MySQL import just the DATE portion or is there any way to have Access export only the DATE portion?

How To Add A New Row To An Existing Table?
I am able to create database, tables, inserting values, and so forth. My question is this:

Let's say I have a table on the list of items I owned, and some time later, I need to add a new item between after row 12 and before 13. How do I do that? I did look at MySQL 5.0 Manual and didn't find anything similar to what I wanted to do.

Foreign Key To Existing Table?
Is it possible to add a foreign key to a table that already exists? Or do I have to drop the table and recreate it?

Insert Row Into Existing Table
I have a table with rougly 70 threads, I now need to go back and insert a couple new entries into my table, but they cant go at the end, they need to go in the middle, say like ID 40,41,and 42. How do I do this?

Copy Of An Existing Table
MySQL: How I make a copy of an existing table in phpMyAdmin or SQL ?

without copy data
with copy and data

Assigning Userids To Existing Table
I have a table of existing users in a database. I want to add a "userid" column to the database that automatically assigns an ID to each user when new accounts are added to the system. I know I would do something like this if I had the brains to have added the column at the time of creating the table:

ALTER TABLE writers ADD (
userid int PRIMARY KEY auto_increment
);

However, the table is now already active with users, and I want userids assigned to existing accounts on the system.

How To Add A Auto_increment Field To An Existing Table
I want to add a field called "id" starting from 1 and auto increment, but it seems that mysql doesn't allow me to do the following.

alter table existing_table add id INT AUTO_increment;

Message: Incorrect table definition; there can be only one auto column and it must be defined as a key. But I don't have a key or auto column in the existing_table.

Adding A Foreign Key Into An Existing Table
May I know how should I do that?

The SQL statement should be:

CREATE TABLE USER_SYSTEM_SECURITY (
USERID VARCHAR(32),
HOSTID VARCHAR(32),
HOME_DIRECTORY VARCHAR(32) NOT NULL,
ACCESS_RIGHTS INT(3) NOT NULL,
PASSWORD_EXPIRY_DATE DATE,
ROLES VARCHAR(32) NOT NULL,
PRIMARY KEY (USERID, HOSTID),
FOREIGN KEY (USERID) REFERENCES MEMBER (USERID) ON DELETE CASCADE,
FOREIGN KEY (HOSTID) REFERENCES SYSTEM (HOSTID) ON DELETE CASCADE);

But I forgot to add in the last row during the table creation.

Search Table Column For Existing Value
I would like to search a table's column so that I can match an entered email address against the data in that column. I'm writing an aplication for an event and I don't want duplicate email addresses in the table. I'm using PHP4.

Auto Increment Existing Table
I have an existing table with many rows of data. I want to add auto increment to it so I do not have to manually asign each row a unique record number.

Modifying Primary Key And Auto_increment In Pre-existing Table
Given the tables defined below, is there a sql statement that could make num_1 an auto_increment field without rebuilding the table (nevermind any potential numbering conflicts)? I don't see anything in the alter table documentation that will produce this effect.

Also, say I wanted to change the primary key of test_1 (e.g. primary key(num_1,num_2)). I think because num_1 is a foreign key for the table test_2 MySQL grumbles about changing the primary key, in addition to dissalowing the drop and redefinition of the primary key.

Could anyone tell me how to easily handle these situations? This is a simplified example of my actual situaion, but if it can be solved here then I think I would be OK. Code:

How Do You Discern The Type Of An Existing Mysql Table Column?
I have a program that needs to be able to know whether a MySQL column is a number type or other. Is there a function that does this, or can anyone else suggest a way of discerning this reliably using SQL statements?

Zero Rows Or One Rows Returned, Same Data And Same Query
I have a query that produces a single row (as I expect) when I run it from the mysql client (mysql 4.0.18-Max/linux, also 5.0.19-standard/OSX-intel), or from sqlgrinder (osx, uses jdbc).

When I run it inside my application (a Java app connecting via jdbc), I get zero rows from this query.

I tried it under phpmyadmin, and once again I get zero rows.

Why do I get inconsistent results? Here's the query:

Import Data
I am using 5.0.26, community version

The sql file is at c:db.sql

I tried

mysql -u root -p 11111 db < c:db.sql (or enclosed by '', ``)

does not work

mysql -u root -p db < "c:db.sql" (or enclosed by '', ``)

does not work

mysqlimport db < "c:db.sql" (or enclosed by '', ``)

does not work.

Import Data
we have designed an application which contacted with a MySQL database. A client of ours wants to pre-collect data to a Windows-based database like MS SQL, or Microsoft Access. How it is possible to import these data into the MySQL database successfully and with no problems? Also, the character encoding is set to Unicode UTF-8. Which database supports Unicode in order to eliminate possible conflicts?

Import Data
how can i a import data to mysql from such as sql server 2000 or acces ?

Import Old Data To New
My machine was down before, fortunately I have back up the whole
/usr/local/mysql directory. Now I have setup a new mysql on a new
machine, how can I import the old data back to the new database??

My old mysql version: mysql-3.22.32
new mysql version: mysql-max-4.0.3-beta-sun-solaris2.7.sparc

I used to run the mysql like this:

/usr/local/mysql/bin/mysql abc

should I add the user abc to my new database first? and how?

Import Data
how can i import data from sql server 2000 to mysql ?
and please give some site to download mysql utilities ?

Import Data
I am import data from csv with sqlyog, but always have warnings and I canīt import it.

My configuration is:

- Terminated By: ;
- Enclosed by: ;
- Escaped by: ;

- Fields terminated by: ;
- Fields enclosed by: ;

Import A Bunch Of Data In CLI
I am able to login fine via ssh and then I can get into mysql fine via CLI. My problem is that I need to import a 100MB file into a specific database. What should I do?

How To Export Or Import Data
how to import data from mysql to another database. & how to export data from another data base to mysql.

Import Data From MSSQL
I have two systems, one using MSSQL and one using MySQL. On a daily basis, I need to import information from tables on the MSSQL database to a table on the MySQL database.
What's the easiest way to do this?

Error Import Data
I exported data with mysqldump, and now i want to import it in another pc, mysql version same. but i got error:

ERROR 1064 (42000) at line 57: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''ADTIVAVELDTYPNTDIGDPSYPHIGIDIKSVRSKKTAKWNMQNGKVGTAHIIYNSVDKRLSAVVSYPNADSATVSYDV' at line 1

how i could fix it?


Copyright Đ 2005-08 www.BigResource.com, All rights reserved