Advertisement
GigilinE

Untitled

Mar 18th, 2021
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. select
  2. b.`ID` AS `ID`,
  3. c.`product_id` AS `product_id`,
  4. c.`nome_prodotto` AS `nome_prodotto`,
  5. c.`link_prodotto` AS `link_prodotto`,
  6. c.`img_link` AS `img_link`,
  7. c.`prezzo` AS `prezzo`,
  8. c.`fornitore` AS `fornitore`,
  9. c.`contatto_fornitore_1` AS `contatto_fornitore_1`,
  10. c.`contatto_fornitore_2` AS `contatto_fornitore_2`,
  11. c.`descrizione` AS `descrizione`,
  12. c.`disponibili` AS `quantity_max`,
  13. c.`disponibili_oggi` AS `disponibili_oggi`,
  14. c.`venditore` AS `venditore`,
  15. c.`venditore_es` AS `venditore_es`,
  16. c.`venditore_en` AS `venditore_en`,
  17. c.`venditore_fr` AS `venditore_fr`,
  18. c.`venditore_de` AS `venditore_de`,
  19. c.`nome_prodotto_en` AS `nome_prodotto_en`,
  20. c.`nome_prodotto_fr` AS `nome_prodotto_fr`,
  21. c.`nome_prodotto_de` AS `nome_prodotto_de`,
  22. c.`nome_prodotto_es` AS `nome_prodotto_es`,
  23. c.`prezzo_en` AS `prezzo_en`,
  24. c.`prezzo_fr` AS `prezzo_fr`,
  25. c.`prezzo_de` AS `prezzo_de`,
  26. c.`prezzo_es` AS `prezzo_es`,
  27. c.`fornitore_en` AS `fornitore_en`,
  28. c.`fornitore_fr` AS `fornitore_fr`,
  29. c.`fornitore_de` AS `fornitore_de`,
  30. c.`fornitore_es` AS `fornitore_es`,
  31. c.`descrizione_en` AS `descrizione_en`,
  32. c.`descrizione_fr` AS `descrizione_fr`,
  33. c.`descrizione_de` AS `descrizione_de`,
  34. c.`descrizione_es` AS `descrizione_es`,
  35. c.`disponibili_en` AS `disponibili_en`,
  36. c.`disponibili_fr` AS `disponibili_fr`,
  37. c.`disponibili_de` AS `disponibili_de`,
  38. c.`disponibili_es` AS `disponibili_es`,
  39. c.`link_prodotto_es` AS `link_prodotto_es`,
  40. c.`link_prodotto_en` AS `link_prodotto_en`,
  41. c.`link_prodotto_fr` AS `link_prodotto_fr`,
  42. c.`link_prodotto_de` AS `link_prodotto_de`,
  43. c.`cat_it` AS `cat_it`,
  44. c.`cat_es` AS `cat_es`,
  45. c.`cat_de` AS `cat_de`,
  46. c.`cat_en` AS `cat_en`,
  47. c.`cat_fr` AS `cat_fr`,
  48. a.`user_login` AS `user_login`,
  49. a.`ID` AS `user_id`,
  50. a.`email` AS `email`,
  51. b.`quantity` AS `quantity_ask`,
  52. b.`date` AS `date`,
  53. (
  54. SELECT
  55. SUM(h.prezzo * g.quantity) AS total_price_prod
  56. FROM
  57. amz_usr as f inner join amz_cart as g on f.ID = g.user_id inner join amz_prod as h on g.product_id = h.product_id
  58. WHERE
  59. c.`product_id` = g.`product_id` AND a.`ID` = g.`user_id`
  60. ) AS `total_price_prod`,
  61. (
  62. SELECT
  63. SUM(a.quantity) AS total
  64. FROM
  65. amz_cart a INNER JOIN amz_prod b ON a.product_id = b.product_id
  66. WHERE
  67. c.`product_id` = b.`product_id` and
  68. date_format(from_unixtime(b.`date`), '%d') = dayofmonth(curdate()) and
  69. date_format(from_unixtime(b.`date`),'%m') = month(curdate()) and
  70. date_format(from_unixtime(b.`date`),'%Y') = year(curdate())
  71. ) AS `oggi`,
  72. (
  73. SELECT
  74. SUM(a.quantity) AS total
  75. FROM
  76. amz_cart a INNER JOIN amz_prod b ON a.product_id = b.product_id
  77. WHERE
  78. c.`product_id` = b.`product_id` and
  79. date_format(from_unixtime(b.`date`),'%m') = month(curdate()) and
  80. date_format(from_unixtime(b.`date`),'%Y') = year(curdate())
  81. ) AS `mese`,
  82. (
  83. SELECT
  84. SUM(a.quantity) AS total
  85. FROM
  86. amz_cart a INNER JOIN amz_prod b ON a.product_id = b.product_id
  87. WHERE
  88. c.`product_id` = b.`product_id` and
  89. date_format(from_unixtime(b.`date`),'%Y') = year(curdate())
  90. ) AS `anno`,
  91. (
  92. SELECT
  93. SUM(a.quantity) AS total
  94. FROM
  95. amz_cart a INNER JOIN amz_prod b ON a.product_id = b.product_id
  96. WHERE
  97. c.`product_id` = b.`product_id`
  98. ) AS `totali`
  99. from
  100. amz_usr as a inner join amz_cart as b on a.ID = b.user_id inner join amz_prod as c on b.product_id = c.product_id;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement