1. Список говнокодов пользователя fosco

    Всего: 1

  2. SQL / Говнокод #6288

    −855

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    SELECT h.*,
    			      if(h.gender_id != 0, (SELECT g.title FROM p_cm5_horses_gender g WHERE h.gender_id = g.id AND h.lang_id = g.lang_id),"") AS gender,
    			        if(h.colour_id != 0, (SELECT c.title FROM p_cm5_horses_colour c WHERE h.colour_id = c.id AND h.lang_id = c.lang_id),"") AS colour,
    			        if(h.color_group != 0, (SELECT cg.title FROM p_cm5_horses_colour_group cg WHERE h.color_group = cg.id AND h.lang_id = cg.lang_id),"") AS color_group_name,
    			        if(h.temper_id != 0, (SELECT t.title FROM p_cm5_horses_temper t WHERE h.temper_id = t.id AND h.lang_id = t.lang_id),"") AS temper,
    			        if(h.grading_id != 0, (SELECT t.title FROM p_cm5_horses_grading t WHERE h.temper_id = t.id AND h.lang_id = t.lang_id),"") AS grading,
    			        if(h.breed_id != 0, (SELECT b.title FROM p_cm5_horses_studbook b WHERE h.breed_id = b.id AND h.lang_id = b.lang_id),"") AS breed,
    			        if(h.training_first != 0, (SELECT t.training_name FROM p_cm5_horses_training t WHERE h.training_first = t.id AND h.lang_id = t.lang_id),"") AS training_first_name,
    			        if(h.level_first != 0, (SELECT t.level_name FROM p_cm5_horses_training_level t WHERE h.level_first = t.id AND h.lang_id = t.lang_id),"") AS level_first_name,
    			        if(h.training_second != 0, (SELECT t.training_name FROM p_cm5_horses_training t WHERE h.training_second = t.id AND h.lang_id = t.lang_id),"") AS training_second_name,
    			        if(h.level_second != 0, (SELECT t.level_name FROM p_cm5_horses_training_level t WHERE h.level_second = t.id AND h.lang_id = t.lang_id),"") AS level_second_name,
    			        if(h.price_id != 0, (SELECT p.title FROM p_cm5_horses_price p WHERE h.price_id = p.id AND h.lang_id = p.lang_id),"") AS price,
    			        if(h.price_id != 0, (SELECT p.title FROM p_cm5_horses_price p WHERE h.price_id = p.id AND p.lang_id = 2),"") AS price2
    			        FROM p_cm5_horses h
    			        WHERE h.enabled = 1 AND h.lang_id = 1 AND h.id = 219

    копался в одном проекте который нам отдали на аутсорс, нашел своего рода LEFT JOIN-ины

    fosco, 08 Апреля 2011

    Комментарии (2)