Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Commit

Permalink
just an edit ;)
Browse files Browse the repository at this point in the history
  • Loading branch information
moratab committed May 28, 2018
1 parent bf81a6e commit a6452fa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions database/script.sql
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ CREATE TABLE IF NOT EXISTS `post_details` (`MasterID` INT, `Title` INT, `ID` INT
-- View `post_contents`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `post_contents`;
USE `gordcms`;

CREATE OR REPLACE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `post_contents` AS select `P`.`MasterId` AS `MasterId`,`P`.`Id` AS `Id`,`P`.`Title` AS `Title`,`P`.`Submit` AS `Submit`,`P`.`Type` AS `Type`,`P`.`Level` AS `Level`,`P`.`Body` AS `Body`,`P`.`UserId` AS `UserId`,`P`.`Status` AS `Status`,`P`.`RefrenceId` AS `RefrenceId`,`P`.`Index` AS `Index`,`P`.`Deleted` AS `Deleted`,`P`.`ContentDeleted` AS `ContentDeleted`,`users`.`Username` AS `Username`,(select `P0`.`Content` AS `Content` from `posts` `P0` where ((`P0`.`Content` is not null) and (`P`.`MasterId` = `P0`.`MasterId`)) order by `P0`.`Submit` desc limit 1) AS `Content`,(select `P1`.`Submit` AS `D1` from `posts` `P1` where ((`P1`.`Content` is not null) and (`P`.`MasterId` = `P1`.`MasterId`)) order by `P1`.`Submit` desc limit 1) AS `D1`,(select `P2`.`Submit` AS `D2` from `posts` `P2` where ((`P2`.`ContentDeleted` = 1) and (`P`.`MasterId` = `P2`.`MasterId`)) order by `P2`.`Submit` desc limit 1) AS `D2` from (`posts` `P` join `users` on((`P`.`UserId` = `users`.`Id`))) where (`P`.`Id` in (select max(`posts`.`Id`) from `posts` group by `posts`.`MasterId`) and (`P`.`Deleted` = 0));

-- -----------------------------------------------------
-- View `post_details`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `post_details`;
USE `gordcms`;

CREATE OR REPLACE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `post_details` AS select `T`.`MasterId` AS `MasterID`,`T`.`Title` AS `Title`,`T`.`Id` AS `ID`,`T`.`Submit` AS `Submit`,`T`.`UserId` AS `UserID`,`T`.`Username` AS `Username`,`T`.`Body` AS `Body`,`T`.`Type` AS `Type`,`T`.`Level` AS `Level`,`T`.`RefrenceId` AS `RefrenceID`,`T`.`Index` AS `Index`,`T`.`Status` AS `Status`,(case when (`T`.`D2` >= `T`.`D1`) then NULL else `T`.`Content` end) AS `Content` from `post_contents` `T`;

SET SQL_MODE=@OLD_SQL_MODE;
Expand Down

0 comments on commit a6452fa

Please sign in to comment.