1. SQL / Говнокод #11177

    −153

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    SELECT count(*) as cnt FROM cms_books AS b  	
    	JOIN (SELECT DISTINCT r.book_id FROM cms_book2cat AS r
    	JOIN (SELECT 40 AS category_id 
    		UNION SELECT 105 AS category_id UNION SELECT 212 AS category_id UNION SELECT 404 AS category_id UNION SELECT 1 AS category_id UNION SELECT 2 AS category_id UNION SELECT 3 AS category_id UNION SELECT 5 AS category_id UNION SELECT 62 AS category_id UNION SELECT 60 AS category_id UNION SELECT 59 AS category_id UNION SELECT 58 AS category_id UNION SELECT 55 AS category_id UNION SELECT 54 AS category_id UNION SELECT 51 AS category_id UNION SELECT 50 AS category_id UNION SELECT 49 AS category_id UNION SELECT 71 AS category_id UNION SELECT 72 AS category_id UNION SELECT 78 AS category_id UNION SELECT 85 AS category_id UNION SELECT 86 AS category_id UNION SELECT 90 AS category_id UNION SELECT 91 AS category_id UNION SELECT 92 AS category_id UNION SELECT 94 AS category_id UNION SELECT 96 AS category_id UNION SELECT 101 AS category_id UNION SELECT 156 AS category_id UNION SELECT 157 AS category_id UNION SELECT 222 AS category_id UNION SELECT 226 AS category_id UNION SELECT 398 AS category_id UNION SELECT 406 AS category_id UNION SELECT 407 AS category_id UNION SELECT 416 AS category_id UNION SELECT 417 AS category_id UNION SELECT 890 AS category_id UNION SELECT 106 AS category_id UNION SELECT 108 AS category_id UNION SELECT 111 AS category_id UNION SELECT 115 AS category_id UNION SELECT 152 AS category_id UNION SELECT 121 AS category_id UNION SELECT 125 AS category_id UNION SELECT 159 AS category_id UNION SELECT 195 AS category_id UNION SELECT 257 AS category_id UNION SELECT 262 AS category_id UNION SELECT 302 AS category_id UNION SELECT 306 AS category_id UNION SELECT 397 AS category_id UNION SELECT 401 AS category_id UNION SELECT 402 AS category_id UNION SELECT 403 AS category_id UNION SELECT 413 AS category_id UNION SELECT 414 AS category_id UNION SELECT 213 AS category_id UNION SELECT 214 AS category_id UNION SELECT 215 AS category_id UNION SELECT 216 AS category_id UNION SELECT 217 AS category_id UNION SELECT 4 AS category_id UNION SELECT 477 AS category_id UNION SELECT 45 AS category_id UNION SELECT 10 AS category_id UNION SELECT 9 AS category_id UNION SELECT 11 AS category_id UNION SELECT 65 AS category_id UNION SELECT 64 AS category_id UNION SELECT 63 AS category_id UNION SELECT 61 AS category_id UNION SELECT 57 AS category_id UNION SELECT 56 AS category_id UNION SELECT 53 AS category_id UNION SELECT 52 AS category_id UNION SELECT 48 AS category_id UNION SELECT 47 AS category_id UNION SELECT 46 AS category_id UNION SELECT 43 AS category_id UNION SELECT 44 AS category_id UNION SELECT 66 AS category_id UNION SELECT 67 AS category_id UNION SELECT 68 AS category_id UNION SELECT 69 AS category_id UNION SELECT 70 AS category_id UNION SELECT 73 AS category_id UNION SELECT 74 AS category_id UNION SELECT 75 AS category_id UNION SELECT 76 AS category_id UNION SELECT 77 AS category_id UNION SELECT 79 AS category_id UNION SELECT 80 AS category_id UNION SELECT 81 AS category_id UNION SELECT 82 AS category_id UNION SELECT 83 AS category_id UNION SELECT 84 AS category_id UNION SELECT 87 AS category_id UNION SELECT 88 AS category_id UNION SELECT 89 AS category_id UNION SELECT 93 AS category_id UNION SELECT 95 AS category_id UNION SELECT 97 AS category_id UNION SELECT 98 AS category_id UNION SELECT 102 AS category_id UNION SELECT 103 AS category_id UNION SELECT 109 AS category_id UNION SELECT 112 AS category_id UNION SELECT 113 AS category_id UNION SELECT 114 AS category_id UNION SELECT 116 AS category_id UNION SELECT 117 AS category_id UNION SELECT 119 AS category_id UNION SELECT 122 AS category_id UNION SELECT 123 AS category_id UNION SELECT 124 AS category_id UNION SELECT 126 AS category_id UNION SELECT 133 AS category_id UNION SELECT 134 AS category_id UNION SELECT 137 AS category_id UNION SELECT 142 AS category_id UNION SELECT 146 AS category_id UNION SELECT 149 AS category_id UNION SELECT 153 AS category_id UNION SELECT 155 AS category_id UNION SELECT 158 AS category_id UNION SELECT 160 AS category_id UNION SELECT 162 AS category_id UNION SELECT 163 AS category_id UNION SELECT 169 AS category_id UNION SELECT 176 AS category_id UNION SELECT 185 AS category_id UNION SELECT 193 AS category_id UNION SELECT 194 AS category_id UNION SELECT 196 AS category_id UNION SELECT 197 AS category_id UNION SELECT 198 AS category_id UNION SELECT 199 AS category_id UNION SELECT 200 AS category_id UNION SELECT 202 AS category_id UNION SELECT 205 AS category_id UNION SELECT 207 AS category_id UNION SELECT 208 AS category_id UNION SELECT 209 AS category_id UNION SELECT 210 AS category_id UNION SELECT 211 AS category_id UNION SELECT 228 AS category_id UNION SELECT 221 AS category_id UNION SELECT 224 AS category_id UNION SELECT 225 AS category_id UNION SELECT 238 AS category_id UNION SELECT 249 AS category_id UNION SELECT 250 AS category_id UNION SELECT 254 AS category_id UNION SELECT 255 AS category_id UNION SELECT 256 AS category_id UNION SELECT 258 AS category_id UNION SELECT 259 AS category_id UNION SELECT 263 AS category_id UNION SELECT 264 AS category_id UNION SELECT 265 AS category_id UNION SELECT 266 AS category_id UNION SELECT 267 AS category_id UNION SELECT 268 AS category_id UNION SELECT 269 AS category_id UNION SELECT 270 AS category_id UNION SELECT 271 AS category_id UNION SELECT 272 AS category_id UNION SELECT 274 AS category_id UNION SELECT 275 AS category_id UNION SELECT 276 AS category_id UNION SELECT 277 AS category_id UNION SELECT 278 AS category_id 
    	AS c ON (c.category_id=r.category_id)) AS br ON (b.book_id=br.book_id)
    WHERE 1

    половину пришлось отрезать - форма не пускала. Общая длина запроса - более 12k
    задача - выбрать кол-во книг из текущей категории и всех вложенных

    Запостил: IntenT, 18 Июня 2012

    Комментарии (23) RSS

    Добавить комментарий