Guest User

Untitled

a guest
May 28th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. | id_img | id_immobile | id_utente | img_url | type | visible_website | visible_pdf | pdf_img_type | category |
  2. |--------|-------------|-----------|---------|---------|-----------------|-------------|--------------|----------|
  3. | 3 | 1 | 0 | 1.jpg | general | 1 | 1 | foto | foto |
  4.  
  5. | id_immobile | type | id_utente |
  6. |-------------|------|-----------|
  7. | 1 | demo | 90 |
  8.  
  9. SELECT
  10. immobili.id_immobile,
  11. CONCAT(SUBSTRING_INDEX(immagini.img_url, ".", 1), "_thumb.", SUBSTRING_INDEX(immagini.img_url, ".", -1)) as img
  12. FROM immobili
  13. LEFT JOIN immagini
  14. on immagini.id_immobile = immobili.id_immobile
  15. WHERE (immagini.type = "main" OR immagini.type = "general" OR immagini.type IS NULL)
  16. GROUP BY immobili.id_immobile
  17. ORDER BY immobili.data_inserimento DESC, immobili.data_aggiornamento DESC
  18.  
  19. SELECT
  20. immobili.id_immobile,
  21. CONCAT(SUBSTRING_INDEX(immagini.img_url, ".", 1), "_thumb.", SUBSTRING_INDEX(immagini.img_url, ".", -1)) as img
  22. FROM immobili
  23. LEFT JOIN immagini
  24. AND immagini.id_immobile = immobili.id_immobile
  25. AND (immagini.type = "main" OR immagini.type = "general" OR immagini.type IS NULL)
  26. GROUP BY immobili.id_immobile
  27. ORDER BY immobili.data_inserimento DESC, immobili.data_aggiornamento DESC
  28.  
  29. SELECT
  30. i.id_immobile,
  31. CONCAT(SUBSTRING_INDEX(im.img_url, '.', 1), '_thumb.',
  32. SUBSTRING_INDEX(im.img_url, '.', -1)) AS img
  33. FROM immobili i
  34. LEFT JOIN immagini im
  35. ON i.id_immobile = im.id_immobile AND im.type IN ('main', 'general')
  36. ORDER BY
  37. i.data_inserimento DESC,
  38. i.data_aggiornamento DESC;
Add Comment
Please, Sign In to add comment