Page 1 of 1

Help with SQL Query about Clans and Leaders

Posted: Wed Jun 17, 2009 1:04 pm
by nekys
Hello. Due to a mistake by my side, almost all characters are without Clan (including members).

I want someone to make me an SQL query that will take the leader ID from clan_data table and update the clanid on the leader's characters table entry.

So leader has clan ID on the characters table.
clan_data table is not damaged.

Re: Help with SQL Query about Clans and Leaders

Posted: Wed Jun 17, 2009 1:49 pm
by janiii
try this one (be sure to test it on a test table before running on live!)

Code: Select all

update characters set clanid = (select clan_id from clan_data where characters.charId = clan_data.leader_id);

Re: Help with SQL Query about Clans and Leaders

Posted: Thu Jun 18, 2009 11:00 pm
by nekys
Thank you!