Re: Copying distinct data to a new table
Glad that helped! -M - Original Message - From: "Dan Jones" <[EMAIL PROTECTED]> To: "MySQL Mailing List" <[EMAIL PROTECTED]> Sent: Thursday, August 21, 2003 5:46 PM Subject: Re: Copying distinct data to a new table > On Thu, 2003-08-21 at 20:09, Dan Jones wrote: > > 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? > > Sheesh. Nevermind. > > INSERT INTO table (column) SELECT DISTINCT column2 FROM table2; > > If you want to figure something out yourself, post a question to a > mailing list. You'll find the answer within 30 seconds of hitting > "SEND." > > > > > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Copying distinct data to a new table
On Thu, 2003-08-21 at 20:09, Dan Jones wrote: > 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? Sheesh. Nevermind. INSERT INTO table (column) SELECT DISTINCT column2 FROM table2; If you want to figure something out yourself, post a question to a mailing list. You'll find the answer within 30 seconds of hitting "SEND." -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Copying distinct data to a new table
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]