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

-- `eod_authentication`

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


-- ----------------------------------------
-- [`table_account_relationship`]
-- ----------------------------------------

-- 
SELECT COUNT(1) FROM `eod_authentication`.`table_account_relationship`;
SELECT * FROM `eod_authentication`.`table_account_relationship` WHERE (`user_id` = 44);
SELECT * FROM `eod_authentication`.`table_account_relationship` WHERE (`user_id` = 1);

-- 특정 이름에 해당하는 계정 연동 정보
SELECT * FROM `eod_authentication`.`table_account_relationship` 
WHERE (`user_id` = (SELECT `user_id` FROM `eod_authentication`.`table_account_user` WHERE (`nickname` LIKE '데몽헌터')));

-- 특정 시리얼 코드에 해당하는 계정 연동 정보
SELECT * FROM `eod_authentication`.`table_account_relationship` AS relationshipTable
RIGHT JOIN 
(
    SELECT 
        `user_id`, 
        `serial_code`, 
        `nickname`
    FROM `eod_authentication`.`table_account_user` 
    WHERE (`serial_code` LIKE ('noxman'))
) AS accountTable
ON (`relationshipTable`.`user_id` = `accountTable`.`user_id`);

-- 특정 사용자의 Google 계정 연동을 해제하기
-- : 연동 정보를 제거하고, 게스트 상태로 되돌린다.
EXPLAIN UPDATE `eod_authentication`.`table_account_relationship`
SET
    `user_id` = 0,
    `related` = 0
WHERE (`user_id` IN(10000000000002915));

SELECT * FROM `eod_game`.`table_player` WHERE (`user_id` IN(7697));

SELECT * FROM `eod_authentication`.`table_account_relationship`
WHERE (`user_id` = 81);

EXPLAIN UPDATE `eod_authentication`.`table_account_relationship`
SET
    `user_id` = 0,
    `related` = 0
WHERE (`user_id` = (SELECT `user_id` FROM `eod_authentication`.`table_account_user` WHERE (`serial_code` = 'R8VAGIIQDH1R9USO')));


-- 특정 사용자의 Facebook 계정 연동을 해제하기
SELECT * FROM `eod_game`.`table_player` WHERE (`user_id` = 81);
EXPLAIN UPDATE `eod_game`.`table_player`
SET
    `related_account_facebook` = ''
WHERE (`user_id` = 81);



-- ----------------------------------------
-- [`table_account_user`]
-- ----------------------------------------

-- 계정 개수
SELECT COUNT(1) FROM `eod_authentication`.`table_account_user`;

-- 사용자 ID로 계정 찾기
SELECT * FROM `eod_authentication`.`table_account_user` WHERE (`user_id` = 1);

-- 사용자 이름으로 계정 찾기
SELECT * FROM `eod_authentication`.`table_account_user` WHERE (`nickname` = '딸바보s');
SELECT * FROM `eod_authentication`.`table_account_user` WHERE (`nickname` IN('앵김떠줄께', '진양호풋살'));
SELECT * FROM `eod_authentication`.`table_account_user` WHERE (`nickname` = '414');
table_billingtable_billing

SELECT * FROM `eod_authentication`.`table_account_user` 
WHERE (DATE_FORMAT(`join_datetime`, '%Y-%m-%d') = '2017-03-07');

-- 시리얼 코드로 계정 찾기
SELECT * FROM `eod_authentication`.`table_account_user` 
WHERE (`serial_code` IN ('8L66PTG62KUMSV0H'));