-- ================================================================================

--  `eod_community`

-- ================================================================================


-- ----------------------------------------
-- [`table_friend`]
-- ----------------------------------------



-- ----------------------------------------
-- [`table_guild`]
-- ----------------------------------------

SELECT COUNT(1) FROM `eod_community`.`table_guild`;

SELECT * FROM `eod_community`.`table_guild` WHERE (`guild_id` = 10000000000000004);

SELECT * FROM `eod_community`.`table_guild` WHERE (`name` = '빛한별');

-- 길드의 레벨 순위
SELECT * FROM `eod_community`.`table_guild` ORDER BY `level` DESC LIMIT 100;


SELECT * FROM `eod_community`.`table_guild` WHERE (`state` != 3) AND (`master_player_id` = 0);



-- ----------------------------------------
-- [`table_guild_join_request`]
-- ----------------------------------------

SELECT * FROM `eod_community`.`table_guild_join_request` WHERE (`guild_id` = 429);
SELECT * FROM `eod_community`.`table_guild_join_request` 
WHERE (`guild_id` = (SELECT `guild_id` FROM `eod_community`.`table_guild` WHERE (`name` = 'testguild') LIMIT 1));

SELECT * FROM `eod_community`.`table_guild_join_request` WHERE (`guild_id` = 5);


-- 추천 길드 찾기
SELECT
    `guild_id`,
    `name`,
    `mark_code`,
    `description`,
    `level`,
    `experience`,
    `state`,
    `need_join_permission`,
    `master_player_id`,
    `change_name_count`,
    `change_name_datetime`,
    `change_mark_count`,
    `change_mark_datetime`,
    `change_description_count`,
    `change_description_datetime`,
    `skill_reset_count`,
    `war_count`,
    `raid_count`,
    `generate_datetime`
FROM `eod_community`.`table_guild` AS guild
INNER JOIN
(
    SELECT CEIL(RAND() * (SELECT MAX(`guild_id`) FROM `eod_community`.`table_guild`)) AS pickedId
) AS tempGuild
ON (guild.`guild_id` >= tempGuild.pickedId) AND 
   (`state` = 0)
LIMIT 500;


-- ----------------------------------------
-- [`table_guild_membership`]
-- ----------------------------------------

SELECT COUNT(1) FROM `eod_community`.`table_guild_membership` WHERE (`guild_id` = );

-- 길드 멤버 가져오기
SELECT * FROM `eod_community`.`table_guild_membership` WHERE (`guild_id` = 16);
SELECT * FROM `eod_community`.`table_guild_membership` WHERE (`guild_id` = 3);

SELECT * FROM `eod_community`.`table_guild_membership` WHERE (`player_id` = 10000000000000003);

SELECT * FROM `eod_community`.`table_guild_membership` 
WHERE (`guild_id` = (SELECT `guild_id` FROM `eod_community`.`table_guild` WHERE (`name` = 'testguild') LIMIT 1));



-- ----------------------------------------
-- [`table_guild_skill`]
-- ----------------------------------------



-- ----------------------------------------
-- [`table_guild_war_record`]
-- ----------------------------------------



-- ----------------------------------------
-- [`table_party_squad`]
-- ----------------------------------------