SELECT CASE WHEN products_product visibility THEN products_vips user_i

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
SELECT *
CASE
WHEN `products_product`.`visibility` = 'v' THEN `products_vips`.`user_id` IS NULL
WHEN `products_product`.`visibility` = 'i' THEN `products_vips`.`user_id` IS NULL
ELSE 1
END AS `visible`
FROM `products_product` INNER JOIN `products_game` ON (`products_product`.`game_id` = `products_game`.`id`) INNER JOIN `products_vips` ON (`products_game`.`id` = `products_vips`.`game_id`)
WHERE (`products_vips`.`user_id` = 38593023 AND
CASE
WHEN (`products_product`.`visibility` = 'v') THEN (`products_vips`.`user_id` IS NULL)
WHEN (`products_product`.`visibility` = 'i') THEN (`products_vips`.`user_id` IS NULL)
ELSE 1
END = 1)
ORDER BY `products_product`.`priority` DESC LIMIT 21; args=('v', 'i', True, 38593023, 'v', 'i', True, True)