Advertisement
dinhdanvu

Untitled

Dec 12th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. select DISTINCT lower(CONCAT(
  2. ifnull(category,''), ' ; ',
  3. ifnull(publisher,''), ' ; ',
  4. ifnull(manufacturer,'')
  5. )) as data_index,
  6. sku, name, author, category, publisher, manufacturer
  7. from (
  8. (select pe.sku, name.value as name, fs.authors as author, fs.category, fs.publisherName as publisher, ca_manufacturer_ov.value as manufacturer
  9. from fhs_catalog_product_entity pe
  10. JOIN fhs_catalog_product_entity_varchar name ON pe.entity_id = name.entity_id AND name.attribute_id = 71
  11. JOIN fhs_catalog_product_entity_decimal price ON pe.entity_id = price.entity_id AND price.attribute_id = 75
  12. LEFT JOIN fhs_catalog_product_entity_int ca_manufacturer ON ca_manufacturer.entity_id = pe.entity_id AND ca_manufacturer.attribute_id = 81
  13. LEFT JOIN fhs_eav_attribute_option_value ca_manufacturer_ov ON ca_manufacturer_ov.option_id = ca_manufacturer.value
  14. left join fahasa_stock fs on fs.sku = pe.sku
  15. where price.value > 0)
  16.  
  17. union
  18. (
  19. select mabh as sku, tenhh as name, TACGIA as auhor, TENNGANH as category, tenNXB as publisher, tenNCC as manufacturer
  20. from fahasa_ebiz_stock_info ebiz
  21. where length(mabh) > 5)
  22.  
  23. union
  24. (
  25. select sku, name, authors as author, category, publisherName as publisher, null as manufacturer
  26. from fahasa_stock fs
  27. where length(sku) > 5)
  28. ) a
  29. group by sku;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement