Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT DISTINCT `worklist`.`id`,`summary`,`status`,
- `cu`.`nickname` AS `creator_nickname`,
- `ru`.`nickname` AS `runner_nickname`,
- `mu`.`nickname` AS `mechanic_nickname`,
- TIMESTAMPDIFF(SECOND, `created`, NOW()) as `delta`,
- `creator_id`,
- (SELECT COUNT(`bids`.`id`) FROM `bids`
- WHERE `bids`.`worklist_id` = `worklist`.`id` AND (`bids`.`withdrawn` = 0) LIMIT 1) as bid_count,
- TIMESTAMPDIFF(SECOND,NOW(), (SELECT `bids`.`bid_done` FROM `bids`
- WHERE `bids`.`worklist_id` = `worklist`.`id` AND `bids`.`accepted` = 1 LIMIT 1)) as bid_done,
- (SELECT COUNT(`comments`.`id`) FROM `comments`
- WHERE `comments`.`worklist_id` = `worklist`.`id`) AS `comments`FROM `worklist`
- LEFT JOIN `users` AS `cu` ON `worklist`.`creator_id` = `cu`.`id`
- LEFT JOIN `users` AS `ru` ON `worklist`.`runner_id` = `ru`.`id`
- LEFT JOIN `fees` ON `worklist`.`id` = `fees`.`worklist_id`
- LEFT OUTER JOIN `comments` AS `com` ON `worklist`.`id` = `com`.`worklist_id`
- LEFT OUTER JOIN `users` AS `mu` ON `worklist`.`mechanic_id` = `mu`.`id`
- 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