Dan Jones unknowingly asked us:
I'm attempting to normalize a database that was originally created as a
flat file.  I want to extract distinct values from a table and insert
them as new entries into a new table.  Unless I'm missing something,
INSERT doesn't allow you to SELECT data from another table for
insertion, and UPDATE doesn't allow you to create new rows.

I could do a SELECT DISTINCT INTO OUTFILE, then LOAD DATA INFILE but
that seems rather cumbersome.  Is there a straightforward way to do
this?

Yes, INSERT does allow you to SELECT data from another table.


http://www.mysql.com/doc/en/INSERT_SELECT.html

ex:

INSERT INTO tblTemp2 (fldID) SELECT tblTemp1.fldOrder_ID FROM tblTemp1 WHERE tblTemp1.fldOrder_ID > 100;

--
[ Rajesh Kumar ]
__________________________________________
Meet the guy at http://www.meetRajesh.com/


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to