Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Aiheen aloitti: Anguz - helmikuu 13, 2005, 06:13:50 AP

Otsikko: Moving boards in bulk
Kirjoitti: Anguz - helmikuu 13, 2005, 06:13:50 AP
I know this is not available in the Manage Boards area, although it'd be nice. I was wondering what the SQL query would be to move a bunch of boards together. They're childs of board 1 and I want them child of board 2.
Otsikko: Re: Moving boards in bulk
Kirjoitti: [Unknown] - helmikuu 13, 2005, 06:20:05 AP
UPDATE smf_boards
SET ID_PARENT = ###
WHERE ID_BOARD IN (xyz);

-[Unknown]
Otsikko: Re: Moving boards in bulk
Kirjoitti: Midgard - helmikuu 13, 2005, 06:20:50 AP
xyz? board id?
Otsikko: Re: Moving boards in bulk
Kirjoitti: Oldiesmann - helmikuu 14, 2005, 10:04:18 AP
xyz is a list of the board IDs for the boards whose parent you want to change. It allows you to update this value for multiple boards with one query, instead of having to use "WHERE ID_BOARD = 'x' || ID_BOARD = 'y' || ID_BOARD = 'z'" or run a seperate query for each board.
Otsikko: Re: Moving boards in bulk
Kirjoitti: Midgard - helmikuu 14, 2005, 10:09:57 AP
"WHERE ID_BOARD = '1'"

It's true? xyz is board id?
Otsikko: Re: Moving boards in bulk
Kirjoitti: Tony Reid - helmikuu 14, 2005, 10:10:15 AP
Hmmm.. sorry to jump in here... but I want to move a board and its boards into a fresh forum.......

If I did something like a select on the above, would it be as straight forward as an update/insert into the other forum?

I realise I have to share the user DB....

:)

Otsikko: Re: Moving boards in bulk
Kirjoitti: Oldiesmann - helmikuu 14, 2005, 10:22:30 AP
Lainaus käyttäjältä: Midgard - helmikuu 14, 2005, 10:09:57 AP
"WHERE ID_BOARD = '1'"

It's true? xyz is board id?

xyz is a list of the board IDs...

For instance - if you wanted to move boards 5,6 and 7 to board 1, you'd do it like this:

UPDATE smf_boards
SET ID_PARENT = '1'
WHERE ID_BOARD IN (5,6,7);


Lainaus käyttäjältä: Tony - helmikuu 14, 2005, 10:10:15 AP
Hmmm.. sorry to jump in here... but I want to move a board and its boards into a fresh forum.......

If I did something like a select on the above, would it be as straight forward as an update/insert into the other forum?

I realise I have to share the user DB....

:)



INSERT INTO db2.smf_boards
SELECT * FROM db1.smf_boards;
Otsikko: Re: Moving boards in bulk
Kirjoitti: Tony Reid - helmikuu 14, 2005, 10:46:17 AP
Thank you Oldiesmann! :)

I take it that '*' is the id of the board ... and I can do the same with the sub boards :)
Otsikko: Re: Moving boards in bulk
Kirjoitti: Oldiesmann - helmikuu 14, 2005, 11:01:17 AP
* means select everything. I wasn't thinking about moving just some boards. Do it like this (same principle as above for the "WHERE" clause).

INSERT INTO db1.smf_boards
SELECT * FROM db2.smf_boards
WHERE ID_BOARD IN (xyz);
Otsikko: Re: Moving boards in bulk
Kirjoitti: Tony Reid - helmikuu 14, 2005, 11:27:37 AP
Hey thats great - thanks for your help with this :)
Otsikko: Re: Moving boards in bulk
Kirjoitti: Oldiesmann - helmikuu 14, 2005, 11:38:38 AP
No problem.
Otsikko: Re: Moving boards in bulk
Kirjoitti: Anguz - helmikuu 14, 2005, 02:58:24 IP
Thank you [Unknown] and Oldiesmann. :)
Otsikko: Re: Moving boards in bulk
Kirjoitti: Midgard - helmikuu 15, 2005, 03:24:52 AP
Thank you so much Oldiesmann