Advertisement
Guest User

Untitled

a guest
Aug 17th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 2.37 KB | None | 0 0
  1. SELECT HIGH_PRIORITY DISTINCT SQL_CALC_FOUND_ROWS t.id,
  2.                               t.product_type,
  3.                               pq.quantity,
  4.                               pq.available,
  5.                               pq.SIZE,
  6.                               pq.reserved,
  7.                               pq.reserved_auctions
  8. FROM towary t
  9. LEFT JOIN product_quantity pq ON pq.product = t.id
  10. WHERE in_trash = "n"
  11.   AND t.id > "0"
  12.   AND((t.sklep & 71) > 0)
  13.   AND t.data_wpr >= "2012-05-01 00:00:00"
  14.   AND t.data_wpr <= "2018-08-17 23:59:59"
  15.   AND( ( ( t.product_type NOT IN( "product_bundle", "product_collection", "" ) )
  16.         AND( (pq.available & 8)
  17.             AND( ( pq.quantity - pq.reserved + pq.reserved_auctions ) > 0
  18.                 OR pq.quantity = -1 )
  19.             AND( pq.SIZE NOT IN
  20.                   ( SELECT SIZE
  21.                    FROM auctions a
  22.                    WHERE a.product = t.id
  23.                      AND a.active = "y"
  24.                      AND a.account IN(33) ) ) ) )
  25.       OR( ( t.product_type IN( "product_bundle", "product_collection" ) )
  26.          AND(
  27.                ( SELECT COUNT(*)
  28.                 FROM products_bundled_availabilities_buffer buff
  29.                 WHERE buff.bundle_id = t.id
  30.                   AND buff.stocks_type_available & 8
  31.                   AND buff.SIZE NOT IN
  32.                     ( SELECT SIZE
  33.                      FROM auctions a
  34.                      WHERE a.product = buff.product_id
  35.                        AND a.active = "y"
  36.                        AND a.account IN(33) ) ) > 0 ) ) )
  37.   AND( t.id NOT IN
  38.         ( SELECT DISTINCT product AS pid
  39.          FROM auctions
  40.          WHERE ACCOUNT IN(33)
  41.            AND active = "y"
  42.            AND product NOT IN
  43.              ( SELECT DISTINCT (ps.product) AS pid
  44.               FROM product_sizes ps
  45.               LEFT JOIN auctions a ON ps.product = a.product
  46.               AND ps.SIZE = a.SIZE
  47.               AND a.account IN(33)
  48.               AND a.active = "y"
  49.               WHERE ps.product IN
  50.                   ( SELECT DISTINCT product AS pid
  51.                    FROM auctions
  52.                    WHERE ACCOUNT IN(33)
  53.                      AND active = "y" )
  54.                 AND a.SIZE IS NULL ) )
  55.       AND t.version_display_panel = "y" )
  56.   AND t.version_display_panel = "y"
  57. GROUP BY t.id
  58. ORDER BY t.id DESC ,
  59.          t.id DESC LIMIT 0,
  60.                          100
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement