Help - Search - Members - Calendar
Full Version: Need a bit of (My)SQL help
Invision Power Services > Community Forums > Community Web Design and Coding
_
Well, as you may or may not know, I'm completely recoding my site css thesis. I've changed the database structure a bit, and for the most part it's been quite simple.

However. tongue.gif

I've rearranged two (just two) columns in the new structure (and it's pretty crucial how they're ordered); I've read into it, and I'm pretty sure it's not possible to easily rearrange columns. You have to recreate the table. I do however have quite a lot of data in it (to be exact, 30.324 rows), so I'll want that exported as well. Recreating the table really isn't a problem, it moreso is a problem to get all the data over into the new table.

I'm thinking I need to use SELECT .. INTO, is this correct? If so, how would I go about it?
_
Ok, I got it; it was this simple:
SQL
INSERT INTO new_table (foo, bar, baz)
SELECT foo, bar, baz
FROM old_table


Worked almost-perfectly; it had a problem with two non-unique (blink.gif) values apparently conflicting. I just told it to exclude those two and then inserted them afterwards.
Brendon Koz
@all: Pretty sure that wouldn't work with the 3.x series which some hosts still use (as much as they shouldn't). It can always be done with a non-temporary (i.e.: temporary, but not temporary in memory, it would be physical data that you'd create and then delete) table...my GUI MySQL manager will also handle re-ordering of tables (webyog.com), and I would have thought yours would too. Oh well. original.gif

@Veracon: I'm just curious, what was the importance in order for?
_
It's mainly because I sometimes use numeric list indices and I don't want to specifically set the order in the queries (since I've found that to be quite slow). I know, nothing huge, but it's the way I've coded the system (and the code is quite big, so it'd take a while to change, too).
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.