Jump to content

Archived

This topic is now archived and is closed to further replies.

yarub

Moving Some Fields Around?

Recommended Posts

How do I move fields with rows already in it? I'm combining to tables and the fields don't match up.

Table 1
A B [b]C D[/b] E F

Table 2
A B [b]D C[/b] E F

It basically looks like that. There are far too many rows to change each one individually. How can I just switch the two fields around?

Share this post


Link to post
Share on other sites
I don't think you can actually do this without adding a new column in the right place, copying over the data, and then dropping the old column.  But why bother? You can combine two tables however you'd like.

Share this post


Link to post
Share on other sites
How can I do that? I've been trying to do that, but it would appear I do not know how. I can't just drop the id column and add the other database to the the current one. The fields don't match up. So could you explain to me as to how I could o that?

Share this post


Link to post
Share on other sites
That depends what you mean by "combine"...

Share this post


Link to post
Share on other sites
Table 1
A B C D E F

Table 2
A B D C E F

I just want to take all of the rows from Table 2 and put them at the end of Table 1 via the auto increment thinger.

Share this post


Link to post
Share on other sites
You can use "INSERT INTO t1 ( a, b, c, d, e, f ) SELECT a, b, c, d, e, f FROM t2"; how are you currently doing it?

Share this post


Link to post
Share on other sites
How would that work though? The fields do not line up.

Share this post


Link to post
Share on other sites
So?  You can SELECT fields in any order you choose, and INSERT fields in any order as well.

Share this post


Link to post
Share on other sites
Yup... SELECT takes a field list, however you want them back; and insert statement take a column list for that very reason as well.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.