Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select t.* , COUNT(DISTINCT `reserved_amount`.`id`) `reserved_amount_task`
- FROM (SELECT
- `t1`.*,
- `ti`.`id_task` `task_id_favorite`,
- `tm`.`id_task` `task_id_hidden`,
- `bw`.`idu` `id_user_white_list`,
- t1.id as t1id,
- t1.amount as t1amount
- FROM
- `tb_task_w` AS `t1`
- JOIN
- `tb_task_r` `completed` ON `completed`.`id_task` = `t1`.`id` AND `completed`.`status` = 2
- LEFT JOIN
- `tb_task_i` `ti` ON `ti`.`id_user` = 345437 AND `ti`.`id_task` = `t1`.`id`
- LEFT JOIN
- `tb_task_m` `tm` ON `tm`.`id_user` = 345437 AND `tm`.`id_task` = `t1`.`id`
- LEFT JOIN
- `still_block_white` `bw` ON `bw`.`idb` = 345437 AND `bw`.`idu` = `t1`.`id_author`
- WHERE
- `t1`.`id` != '' AND `tm`.`id_task` IS NULL AND `completed`.`id_user` = 345437
- ) t
- LEFT JOIN
- `tb_task_r` `reserved_amount` ON `reserved_amount`.`id_task` = `t`.`t1id` AND `reserved_amount`.`status` IN (0,1)
- GROUP BY
- `t`.`t1id`
- ORDER BY
- `t`.`t1amount` DESC
- LIMIT 0, 30
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement