Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. SELECT
  2. CAST(MD5(CONCAT('collection-', collections.corpus, '-', collections.ident)) AS CHAR (32)) AS guid,
  3. collections.*
  4. FROM (
  5. SELECT
  6. CAST(MD5(CONCAT('collection-', coll_editoriales.ident)) AS CHAR (32)) AS guid_interne,
  7. coll_editoriales.ident,
  8. trim(coll_editoriales.libelle) AS nom_collection,
  9. IF(
  10. coll_editoriales.marq_ident IN (select ident FROM marques WHERE marques.edit_ident IN (1, 21))
  11. OR
  12. (coll_editoriales.edit_ident IN (1) AND coll_editoriales.marq_ident IS NULL),
  13. CASE
  14. WHEN coll_editoriales.edit_ident IN(1, 21) AND coll_editoriales.marq_ident IN ('01V','01Q','01B03','01R','01P','01O','21B') THEN 'flammarion'
  15. WHEN coll_editoriales.edit_ident IN(1) AND coll_editoriales.marq_ident IS NULL AND coll_editoriales.marq_fictive_ident IS NULL THEN 'flammarion'
  16. WHEN coll_editoriales.marq_ident IN('01N') THEN 'arthaud'
  17. WHEN coll_editoriales.marq_ident IN('01C') THEN 'pygmalion'
  18. WHEN coll_editoriales.marq_ident IN('01E-01D') THEN 'jeunesse'
  19. END,
  20. null
  21. ) as corpus,
  22. GROUP_CONCAT(IF(doc_web.document_officiel = 1, CONCAT(doc_web.document_libelle, 'ยง', doc_web.document_emplacement),NULL) SEPARATOR '!') AS sites_web_officiels,
  23. GROUP_CONCAT(IF(doc_web.document_officiel = 0, CONCAT(doc_web.document_libelle, 'ยง', doc_web.document_emplacement),NULL) SEPARATOR '!') AS sites_web_non_officiels
  24.  
  25. FROM coll_editoriales
  26. LEFT JOIN
  27. (
  28. SELECT
  29. documents.libelle as document_libelle,
  30. documents.emplacement as document_emplacement,
  31. documents.cole_ident as document_cole_ident,
  32. documents.officiel as document_officiel
  33. FROM (SELECT * FROM documents WHERE type_docu = 9) as documents
  34. LEFT JOIN type_docus ON type_docus.code = documents.type_docu
  35. )AS doc_web
  36. ON doc_web.document_cole_ident = coll_editoriales.ident
  37. RIGHT OUTER JOIN (
  38. SELECT
  39. DISTINCT(cole_ident)
  40. FROM produits
  41. WHERE
  42. produits.iscommercialisable = 1
  43. ) as produits
  44. ON produits.cole_ident = coll_editoriales.ident
  45. WHERE
  46. coll_editoriales.edit_ident IN(1, 21)
  47. AND (
  48. coll_editoriales.marq_ident IN('01V','01Q','01B03','01R','01P','01O','21B','01N','01C','01E-01D') OR (coll_editoriales.marq_ident IS NULL AND coll_editoriales.edit_ident != 21)
  49. )
  50. AND coll_editoriales.marq_fictive_ident IS NULL
  51. GROUP BY coll_editoriales.ident
  52. ) as collections;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement