Jump to content


Photo

Moving Some Fields Around?


  • Please log in to reply
9 replies to this topic

#1 yarub

yarub
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts
  • LocationSioux City, IA

Posted 01 August 2006 - 10:57 PM

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 C D E F

Table 2
A B D C 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?

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 02 August 2006 - 02:47 PM

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.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 yarub

yarub
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts
  • LocationSioux City, IA

Posted 02 August 2006 - 10:07 PM

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?

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 02 August 2006 - 11:37 PM

That depends what you mean by "combine"...
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 yarub

yarub
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts
  • LocationSioux City, IA

Posted 03 August 2006 - 08:27 AM

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.

#6 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 03 August 2006 - 02:22 PM

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?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#7 yarub

yarub
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts
  • LocationSioux City, IA

Posted 04 August 2006 - 03:58 AM

How would that work though? The fields do not line up.

#8 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 04 August 2006 - 04:09 AM

So?  You can SELECT fields in any order you choose, and INSERT fields in any order as well.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#9 yarub

yarub
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts
  • LocationSioux City, IA

Posted 07 August 2006 - 04:07 AM

:o I did not know that.

#10 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 07 August 2006 - 04:44 AM

Yup... SELECT takes a field list, however you want them back; and insert statement take a column list for that very reason as well.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users