Advertisement
Guest User

Untitled

a guest
May 27th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.51 KB | None | 0 0
  1. SELECT DISTINCT  `worklist`.`id`,`summary`,`status`,
  2.           `cu`.`nickname` AS `creator_nickname`,
  3.           `ru`.`nickname` AS `runner_nickname`,
  4.           `mu`.`nickname` AS `mechanic_nickname`,
  5.           TIMESTAMPDIFF(SECOND, `created`, NOW()) as `delta`,
  6.           `creator_id`,
  7.           (SELECT COUNT(`bids`.`id`) FROM `bids`
  8.            WHERE `bids`.`worklist_id` = `worklist`.`id` AND (`bids`.`withdrawn` = 0) LIMIT 1) as bid_count,
  9.           TIMESTAMPDIFF(SECOND,NOW(), (SELECT `bids`.`bid_done` FROM `bids`
  10.            WHERE `bids`.`worklist_id` = `worklist`.`id` AND `bids`.`accepted` = 1 LIMIT 1)) as bid_done,
  11.            (SELECT COUNT(`comments`.`id`) FROM `comments`
  12.            WHERE `comments`.`worklist_id` = `worklist`.`id`) AS `comments`FROM `worklist`
  13.          LEFT JOIN `users` AS `cu` ON `worklist`.`creator_id` = `cu`.`id`
  14.          LEFT JOIN `users` AS `ru` ON `worklist`.`runner_id` = `ru`.`id`
  15.           LEFT JOIN `fees` ON `worklist`.`id` = `fees`.`worklist_id`
  16.          LEFT OUTER JOIN `comments` AS `com` ON `worklist`.`id` = `com`.`worklist_id`
  17.           LEFT OUTER JOIN `users` AS `mu` ON `worklist`.`mechanic_id` = `mu`.`id`
  18.          
  19.           where (status='WORKING' or 0) AND ( MATCH (summary, `worklist`.`notes`) AGAINST ('LoveMachine')OR MATCH (`fees`.notes) AGAINST ('LoveMachine') OR MATCH (`ru`.`nickname`) AGAINST ('LoveMachine') OR MATCH (`cu`.`nickname`) AGAINST ('LoveMachine') OR MATCH (`mu`.`nickname`) AGAINST ('LoveMachine') OR MATCH (`com`.`comment`) AGAINST ('LoveMachine')) ORDER BY priority ASC LIMIT 0,30
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement