[thelist] merging tables in mysql
Sarah Sweeney
mr.sanders at designshift.com
Fri Aug 20 12:32:03 CDT 2004
> First off, I'd recommend not using SELECT * since it can be a
> bit of a performance hit on higher-traffic sites.
>
> That said, you may be *required* to explicitly select the fields
> for a UNION query, e.g.
>
> SELECT Field1, Field2 FROM Clients1
> UNION
> SELECT Field1, Field2 FROM Clients2
I'm not too worried about using the "SELECT *" in this case (although I
usually don't), as I will only need to do it once to merge the tables.
Plus, it's not a high-traffic site.
I tried both Jonathan's and Peter's suggestions but neither worked - I
guess the UNION is just not allowed in this instance. However, I was
able to do this;
CREATE TABLE Clients ...;
INSERT INTO Clients (SELECT * FROM Clients1);
INSERT INTO Clients (SELECT * FROM Clients2);
which worked fine. I just didn't realize you could build an INSERT
statement in this way. Good to know!
Thanks to Jonathan and Peter for the help!
--
Sarah Sweeney :: Web Developer & Programmer
Portfolio :: http://sarah.designshift.com
Blog :: http://hardedge.ca
Family :: http://geekjock.ca
More information about the thelist
mailing list