Quick query for multiple fields?
Quick query for multiple fields?
am 10.01.2005 17:41:42 von Greg Quinn
I have a table with about 50 fields in it, I want to copy certain records
into another identical table...
i.e
INSERT INTO mail_inbox (userid, subject, message, blah blah....)
(Select userid, subject, message, blah blah... from mail_inboxold where
userid = 10)
Is there an easy way to do this without having to write all the field names
out?
Thanks
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.6.9 - Release Date: 1/6/2005
--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=gcdmw-win32@m.gmane.org
Re: Quick query for multiple fields?
am 11.01.2005 04:20:48 von Petr Vileta
> I have a table with about 50 fields in it, I want to copy certain records
> into another identical table...
>
> i.e
>
> INSERT INTO mail_inbox (userid, subject, message, blah blah....)
> (Select userid, subject, message, blah blah... from mail_inboxold where
> userid = 10)
>
>
> Is there an easy way to do this without having to write all the field
names
> out?
If the fields sequences in both tables are identical you can write
INSERT INTO mail_inbox (userid, subject, message, blah blah....)
(SELECT * FROM mail_inboxold WHERE userid = 10)
Petr Vileta, Czech republic
--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=gcdmw-win32@m.gmane.org
RE: Quick query for multiple fields?
am 11.01.2005 05:06:01 von Tom Crimmins
Accidentally posted this to the general list instead.
---
Tom Crimmins
Interface Specialist
Pottawattamie County, Iowa
-----Original Message-----
From: Tom Crimmins Sent: Monday, January 10, 2005 10:01 PM
To: Greg Quinn
Cc: mysql@lists.mysql.com
Subject: RE: Quick query for multiple fields?
[snip]
I have a table with about 50 fields in it, I want to copy certain records
into another identical table...
i.e
INSERT INTO mail_inbox (userid, subject, message, blah blah....) (Select
userid, subject, message, blah blah... from mail_inboxold where userid = 10)
Is there an easy way to do this without having to write all the field names
out?
[/snip]
If the columns are in the same order you can use the following:
INSERT INTO mail_inbox (SELECT * FROM mail_inboxold WHERE userid=10);
---
Tom Crimmins
Interface Specialist
Pottawattamie County, Iowa
--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=gcdmw-win32@m.gmane.org