Jump to content

VIEWS


seany123

Recommended Posts

Can someone tell me what exactly VIEW is doing in this piece of code??

 

and if it would be possible to edit this to so it can be used with mySQL Version 4.5.

 

 


-- --------------------------------------------------------

CREATE VIEW `guild_scores` AS select `guilds`.`id` AS `guild_id`,((max(`guilds`.`gold`) + sum(`players`.`kills`)) - sum(`players`.`deaths`)) AS `score` from (`guilds` join `players`) where (`players`.`guild_id` = `guilds`.`id`) group by `guilds`.`id` order by ((max(`guilds`.`gold`) + sum(`players`.`kills`)) - sum(`players`.`deaths`)) desc;

-- --------------------------------------------------------

CREATE VIEW `guild_member_ranks` AS (select `gm`.`guild_id` AS `guild_id`,`guilds`.`name` AS `guild_name`,`players`.`id` AS `player_id`,`players`.`username` AS `username`,(case `players`.`username` when `guilds`.`leader` then 1 else 0 end) AS `IsLeader`,`guild_ranks`.`id` AS `rank_id`,`guild_ranks`.`name` AS `rank`,(case `players`.`username` when `guilds`.`leader` then 1 else `guild_ranks`.`admin` end) AS `admin`,(case `players`.`username` when `guilds`.`leader` then 1 else `guild_ranks`.`kick` end) AS `kick`,(case `players`.`username` when `guilds`.`leader` then 1 else `guild_ranks`.`invite` end) AS `invite`,(case `players`.`username` when `guilds`.`leader` then 1 else `guild_ranks`.`officers` end) AS `officers`,(case `players`.`username` when `guilds`.`leader` then 1 else `guild_ranks`.`treasury` end) AS `treasury` from (((`guild_members` `gm` join `players` on((`gm`.`player_id` = `players`.`id`))) join `guilds` on((`guilds`.`id` = `gm`.`guild_id`))) left join `guild_ranks` on((`gm`.`rank_id` = `guild_ranks`.`id`))));

 

 

Link to comment
Share on other sites

i said 4.5ish because i know that the mysql version is around that area.

 

so its possible to just use the select statement...

 

 

EDIT: ive just switched hosts from freehostia.com -> awardspace.net... so im gonna be able to use mysql v5 after all.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.