{"id":335280,"date":"2022-07-03T21:00:29","date_gmt":"2022-07-03T21:00:29","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=335280"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=335280","title":{"rendered":"<span>\u041f\u0435\u0439\u0434\u0436\u0438\u043d\u0433 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0432 \u0441\u043e\u0446\u0441\u0435\u0442\u044f\u0445<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d LIMIT \u0432 Mysql, OFFSET LIMIT \u0432 Postgres \u0438 TOP \u0432 MSSQL. \u0418\u043c\u0435\u043d\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043d\u0438\u0445 \u0438 \u0434\u0435\u043b\u0430\u044e\u0442 \u043f\u0435\u0439\u0434\u0436\u0438\u043d\u0433 \u0441\u0442\u0440\u0430\u043d\u0438\u0446. \u041e\u0434\u043d\u0430\u043a\u043e \u0447\u0442\u043e\u0431\u044b \u0441\u043c\u0435\u0441\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c, \u0443\u0441\u043b\u043e\u0432\u0438\u044e (WHERE) \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 sql-\u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430\u0447\u043d\u0451\u0442 \u0442\u043e\u0440\u043c\u043e\u0437\u0438\u0442\u044c.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0431\u0440\u043e\u0441\u0438\u043c \u0432\u0437\u0433\u043b\u044f\u0434 \u043d\u0430 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<pre><code class=\"pgsql\">SELECT product.id FROM product WHERE product.price > 3000 AND product.brand=\"Love Republic\" AND EXISTS(SELECT 1             FROM stock JOIN shop             ON stock.shop_id=shop.id            WHERE stock.product_id=product.id            AND shop.city_code=7800000000            LIMIT 1           ) ORDER BY product.innovation DESC LIMIT 1000000, 10<\/code><\/pre>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u043a\u043b\u0438\u0435\u043d\u0442 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430 \u0440\u0435\u0448\u0438\u043b \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0442\u043e\u0432\u0430\u0440\u043e\u0432 \u0441\u0440\u0430\u0437\u0443 \u043d\u0430 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0443. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432 WHERE \u043a \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430\u043c \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u043f\u043e\u043a\u0430 \u043c\u044b \u0434\u043e\u0439\u0434\u0451\u043c \u0434\u043e \u043d\u0443\u0436\u043d\u044b\u0445.<\/p>\n<p>\u0415\u0441\u0442\u044c \u043b\u0438 \u0441\u043f\u043e\u0441\u043e\u0431 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c OFFSET, \u0430 \u0441\u0440\u0430\u0437\u0443 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443? \u0422\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0435\u0441\u0442\u044c. \u041f\u0440\u0430\u0432\u0434\u0430 \u043e\u043d \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u043e\u0436\u0435\u0440\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u043c\u0435\u0440\u0430\u043c\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430. \u0422\u0430\u043a \u0432\u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 GET \/products\/? page=100000&amp;order=innovation, \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 GET \/products\/?order=innovation&amp;page=2021-12-12,5000.<\/p>\n<pre><code class=\"pgsql\">SELECT product.id FROM product WHERE  product.innovation &lt; \"2021-12-12\" OR product.innovation=\"2021-12-12\" AND product.id >= 5000 ... ORDER BY product.innovation DESC, product.id ASC LIMIT 10<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u0435\u043d \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c\u0443. \u0422\u0440\u043e\u0435\u0442\u043e\u0447\u0438\u0435\u043c \u044f \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c\u0438. \u0421\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0436\u0435 \u0431\u044b\u043b\u043e \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u043e \u043d\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f: \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 <strong>innovation<\/strong> \u0442\u0443\u0442 \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u0442\u043e\u0432\u0430\u0440\u0430\u043c \u043d\u0443\u0436\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0432\u0430\u0440\u043e\u0432 \u043c\u043e\u0433\u043b\u0438 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u0434\u0430\u0442\u0443, \u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u043f\u043e\u043b\u044f\u043c, \u0442\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u0432 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0435 \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u043e\u043b\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u0432\u043e\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f (\u0435\u0441\u043b\u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 ASC \u0438 \u043c\u0435\u043d\u044c\u0448\u0435 \u0434\u043b\u044f DESC), \u0430 \u0437\u0430\u0442\u0435\u043c \u0447\u0435\u0440\u0435\u0437 OR, \u0435\u0441\u043b\u0438 \u0436\u0435 \u043f\u043e\u043b\u0435 \u0440\u0430\u0432\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u043c\u0443 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043f\u043e\u043b\u0435 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f ORDER BY product.innovation DESC, product.price, product.id:<\/p>\n<pre><code class=\"sql\">(product.innovation &lt; 2021-12-12 OR product.innovation = 2021-12-12 AND product.price > 610 OR product.innovation = 2021-12-12 AND product.price = 610 AND product.id >= 5000)<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 sql-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0432\u0440\u043e\u0434\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>make_query_for_order <\/strong>\u043d\u0430 perl:<\/p>\n<pre><code class=\"perl\">use strict; use warnings;  # \u041e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442 \u0441\u0442\u0440\u043a\u0438 \u0432 \u043e\u0434\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u043a\u0430\u0432\u044b\u0447\u043a\u0438, \u0430 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 sub quote { my ($value) = @_; $value =~ \/^-?\\d+(\\.\\d+)?$\/? $value: do { $value =~ s\/'\/\\\\'\/g; \"$value\" } }  # \u0421\u043e\u0437\u0434\u0430\u0451\u0442 \u0447\u0430\u0441\u0442\u0438 sql-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e, \u0430 \u043d\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0451\u043d\u043d\u043e\u043c\u0443 \u043b\u0438\u043c\u0438\u0442\u0443 sub make_query_for_order(@) {     my ($order, $next) = @_;       my @orders = split \/\\s*,\\s*\/, $order;     my @order_direct;     my @order_sel = map { my $x=$_; push @order_direct, $x =~ s\/\\s+(asc|desc)$\/\/i? uc $1: \"ASC\"; $x } @orders;          my $select = @order_sel==1? $order_sel[0]: join \"\", \"concat(\", join(\",',',\", @order_sel), \")\";       return $select, 1 if $next eq \"\";          my @next = map quote($_), split \/,\/, $next;     my @op = map { \/^A\/? \">\": \"&lt;\" } @order_direct;           # id -> id >= next[0]     # id, update -> id > next[0] OR id = next[0] and      my @whr;     for(my $i=0; $i&lt;@orders; $i++) {         my @opr;         for(my $j=0; $j&lt;=$i; $j++) {             my $eq = $j == $#orders? \"=\": \"\";             if($j != $i) {                 push @opr, \"$order_sel[$j] = $next[$j]\";             } elsif($j != $#orders) {                 push @opr, \"$order_sel[$j] $op[$j] $next[$j]\";             } else {                 push @opr, \"$order_sel[$j] $op[$j]= $next[$j]\";             }         }         push @whr, join \" AND \", @opr;     }     my $where = join \"\\nOR \", map \"$_\", @whr;          return $select, \"($where)\", \\@order_sel; }   $\\ = \"\\n\";  use Data::Dumper;  print Dumper make_query_for_order \"product.innovation DESC, product.price, product.id\", \"\"; print Dumper make_query_for_order \"product.innovation DESC, product.price, product.id\", \"2021-12-12,610,5000\";<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <strong>make_query_for_order<\/strong> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430:<\/p>\n<ol>\n<li>\n<p>$order (\u0441\u0442\u0440\u043e\u043a\u0430): \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0438\u0437 ORDER BY.<\/p>\n<\/li>\n<li>\n<p>$next (\u0441\u0442\u0440\u043e\u043a\u0430): \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 page, \u0442\u043e \u0435\u0441\u0442\u044c &#8212; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u044f\u0442\u0443\u044e.<\/p>\n<\/li>\n<\/ol>\n<p>\u0415\u0441\u043b\u0438 $next \u043f\u0443\u0441\u0442 (\u043d\u0443\u0436\u043d\u0430 \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430), \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0451\u043d \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 \u0434\u0432\u0443\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 &#8212; \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0432 SELECT \u0438 WHERE sql-\u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code class=\"perl\">$VAR1 = 'concat(product.innovation,\\',\\',product.price,\\',\\',product.id)'; $VAR2 = 1;<\/code><\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c sql-\u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0438\u043c:<\/p>\n<pre><code class=\"sql\">SELECT product.id,    concat(product.innovation,product.price,product.id) as next FROM product WHERE  1 ... ORDER BY product.innovation DESC, product.price ASC, product.id ASC LIMIT 11<\/code><\/pre>\n<p>\u0422\u0443\u0442 LIMIT 11, \u0430 \u043d\u0435 10, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0442\u0430\u043a \u0436\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u043e\u0441\u043b\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <strong>next<\/strong> \u043a\u0430\u043a \u043c\u0435\u0442\u043a\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 <strong>2021-12-12,610,5000<\/strong>, \u043a\u0430\u043a \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 \u043d\u0430\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"perl\">$VAR1 = 'concat(product.innovation,\\',\\',product.price,\\',\\',product.id)'; $VAR2 = '(product.innovation &lt; 2021-12-12 OR product.innovation = 2021-12-12 AND product.price > 610 OR product.innovation = 2021-12-12 AND product.price = 610 AND product.id >= 5000)'; $VAR3 = [           'product.innovation',           'product.price',           'product.id'         ];<\/code><\/pre>\n<p>\u0418 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441 <strong>2021-12-12,610,5000<\/strong>:<\/p>\n<pre><code class=\"sql\">SELECT product.id,    concat(product.innovation,product.price,product.id) as next FROM product WHERE  (product.innovation &lt; 2021-12-12 OR product.innovation = 2021-12-12 AND product.price > 610 OR product.innovation = 2021-12-12 AND product.price = 610 AND product.id >= 5000) ... ORDER BY product.innovation DESC, product.price ASC, product.id ASC LIMIT 11<\/code><\/pre>\n<h2>\u0412\u044b\u0432\u043e\u0434\u044b<\/h2>\n<p>\u0422\u0430\u043a\u0430\u044f \u0441\u0445\u0435\u043c\u0430 <em>\u043c\u0435\u0442\u043e\u043a<\/em> \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u0432\u043c\u0435\u0441\u0442\u043e <em>\u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u0438<\/em> \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u043e\u0432. \u0422\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u043d\u043e\u0432\u043e\u0441\u0442\u043d\u043e\u0439 \u043b\u0438\u0441\u0442\u0438\u043d\u0433 \u0432 VK, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u041f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0434\u0430\u043b\u0451\u043a\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e \u043a\u0430\u0440\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (\u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0430\u0442\u044b, \u0442\u043e &#8212; \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044e). \u0417\u0430\u0442\u043e \u044d\u0442\u0438 \u043d\u0435\u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043a\u043e\u043c\u043f\u0435\u043d\u0441\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c \u043a \u043d\u0443\u0436\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443.<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<ol>\n<li>\n<p>\u041f\u0435\u0439\u0434\u0436\u0438\u043d\u0433 \u043d\u0430 \u043c\u0435\u0442\u043a\u0430\u0445 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0435 \u043a\u043d\u0438\u0433 \/ <a href=\"https:\/\/kosmobook.ru\/?next=2022-01-30+00:00:00,1567030\" rel=\"noopener noreferrer nofollow\">https:\/\/kosmobook.ru\/?next=2022-01-30+00:00:00,1567030<\/a>.<\/p>\n<\/li>\n<li>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439 \u0412\u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0435 \/ <a href=\"https:\/\/vk.com\/feed\" rel=\"noopener noreferrer nofollow\">https:\/\/vk.com\/feed<\/a>.<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/674714\/\"> https:\/\/habr.com\/ru\/post\/674714\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d LIMIT \u0432 Mysql, OFFSET LIMIT \u0432 Postgres \u0438 TOP \u0432 MSSQL. \u0418\u043c\u0435\u043d\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043d\u0438\u0445 \u0438 \u0434\u0435\u043b\u0430\u044e\u0442 \u043f\u0435\u0439\u0434\u0436\u0438\u043d\u0433 \u0441\u0442\u0440\u0430\u043d\u0438\u0446. \u041e\u0434\u043d\u0430\u043a\u043e \u0447\u0442\u043e\u0431\u044b \u0441\u043c\u0435\u0441\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c, \u0443\u0441\u043b\u043e\u0432\u0438\u044e (WHERE) \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 sql-\u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430\u0447\u043d\u0451\u0442 \u0442\u043e\u0440\u043c\u043e\u0437\u0438\u0442\u044c.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0431\u0440\u043e\u0441\u0438\u043c \u0432\u0437\u0433\u043b\u044f\u0434 \u043d\u0430 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435:<\/p>\n<pre><code class=\"pgsql\">SELECT product.id FROM product WHERE product.price > 3000 AND product.brand=\"Love Republic\" AND EXISTS(SELECT 1             FROM stock JOIN shop             ON stock.shop_id=shop.id            WHERE stock.product_id=product.id            AND shop.city_code=7800000000            LIMIT 1           ) ORDER BY product.innovation DESC LIMIT 1000000, 10<\/code><\/pre>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u043a\u043b\u0438\u0435\u043d\u0442 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430 \u0440\u0435\u0448\u0438\u043b \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0442\u043e\u0432\u0430\u0440\u043e\u0432 \u0441\u0440\u0430\u0437\u0443 \u043d\u0430 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0443. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432 WHERE \u043a \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430\u043c \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u043f\u043e\u043a\u0430 \u043c\u044b \u0434\u043e\u0439\u0434\u0451\u043c \u0434\u043e \u043d\u0443\u0436\u043d\u044b\u0445.<\/p>\n<p>\u0415\u0441\u0442\u044c \u043b\u0438 \u0441\u043f\u043e\u0441\u043e\u0431 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c OFFSET, \u0430 \u0441\u0440\u0430\u0437\u0443 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443? \u0422\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0435\u0441\u0442\u044c. \u041f\u0440\u0430\u0432\u0434\u0430 \u043e\u043d \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u043e\u0436\u0435\u0440\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u043c\u0435\u0440\u0430\u043c\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430. \u0422\u0430\u043a \u0432\u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 GET \/products\/? page=100000&amp;order=innovation, \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 GET \/products\/?order=innovation&amp;page=2021-12-12,5000.<\/p>\n<pre><code class=\"pgsql\">SELECT product.id FROM product WHERE  product.innovation &lt; \"2021-12-12\" OR product.innovation=\"2021-12-12\" AND product.id >= 5000 ... ORDER BY product.innovation DESC, product.id ASC LIMIT 10<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u0435\u043d \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c\u0443. \u0422\u0440\u043e\u0435\u0442\u043e\u0447\u0438\u0435\u043c \u044f \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u044b\u043c\u0438. \u0421\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0436\u0435 \u0431\u044b\u043b\u043e \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u043e \u043d\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f: \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443 <strong>innovation<\/strong> \u0442\u0443\u0442 \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u0442\u043e\u0432\u0430\u0440\u0430\u043c \u043d\u0443\u0436\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0432\u0430\u0440\u043e\u0432 \u043c\u043e\u0433\u043b\u0438 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u0434\u0430\u0442\u0443, \u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0436\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u043f\u043e\u043b\u044f\u043c, \u0442\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u0432 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0435 \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u043e\u043b\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u0432\u043e\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f (\u0435\u0441\u043b\u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 ASC \u0438 \u043c\u0435\u043d\u044c\u0448\u0435 \u0434\u043b\u044f DESC), \u0430 \u0437\u0430\u0442\u0435\u043c \u0447\u0435\u0440\u0435\u0437 OR, \u0435\u0441\u043b\u0438 \u0436\u0435 \u043f\u043e\u043b\u0435 \u0440\u0430\u0432\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u043c\u0443 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443, \u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043f\u043e\u043b\u0435 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f ORDER BY product.innovation DESC, product.price, product.id:<\/p>\n<pre><code class=\"sql\">(product.innovation &lt; 2021-12-12 OR product.innovation = 2021-12-12 AND product.price > 610 OR product.innovation = 2021-12-12 AND product.price = 610 AND product.id >= 5000)<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 sql-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0432\u0440\u043e\u0434\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>make_query_for_order <\/strong>\u043d\u0430 perl:<\/p>\n<pre><code class=\"perl\">use strict; use warnings;  # \u041e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442 \u0441\u0442\u0440\u043a\u0438 \u0432 \u043e\u0434\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u043a\u0430\u0432\u044b\u0447\u043a\u0438, \u0430 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442 sub quote { my ($value) = @_; $value =~ \/^-?\\d+(\\.\\d+)?$\/? $value: do { $value =~ s\/'\/\\\\'\/g; \"$value\" } }  # \u0421\u043e\u0437\u0434\u0430\u0451\u0442 \u0447\u0430\u0441\u0442\u0438 sql-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e, \u0430 \u043d\u0435 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0451\u043d\u043d\u043e\u043c\u0443 \u043b\u0438\u043c\u0438\u0442\u0443 sub make_query_for_order(@) {     my ($order, $next) = @_;       my @orders = split \/\\s*,\\s*\/, $order;     my @order_direct;     my @order_sel = map { my $x=$_; push @order_direct, $x =~ s\/\\s+(asc|desc)$\/\/i? uc $1: \"ASC\"; $x } @orders;          my $select = @order_sel==1? $order_sel[0]: join \"\", \"concat(\", join(\",',',\", @order_sel), \")\";       return $select, 1 if $next eq \"\";          my @next = map quote($_), split \/,\/, $next;     my @op = map { \/^A\/? \">\": \"&lt;\" } @order_direct;           # id -> id >= next[0]     # id, update -> id > next[0] OR id = next[0] and      my @whr;     for(my $i=0; $i&lt;@orders; $i++) {         my @opr;         for(my $j=0; $j&lt;=$i; $j++) {             my $eq = $j == $#orders? \"=\": \"\";             if($j != $i) {                 push @opr, \"$order_sel[$j] = $next[$j]\";             } elsif($j != $#orders) {                 push @opr, \"$order_sel[$j] $op[$j] $next[$j]\";             } else {                 push @opr, \"$order_sel[$j] $op[$j]= $next[$j]\";             }         }         push @whr, join \" AND \", @opr;     }     my $where = join \"\\nOR \", map \"$_\", @whr;          return $select, \"($where)\", \\@order_sel; }   $\\ = \"\\n\";  use Data::Dumper;  print Dumper make_query_for_order \"product.innovation DESC, product.price, product.id\", \"\"; print Dumper make_query_for_order \"product.innovation DESC, product.price, product.id\", \"2021-12-12,610,5000\";<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <strong>make_query_for_order<\/strong> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430:<\/p>\n<ol>\n<li>\n<p>$order (\u0441\u0442\u0440\u043e\u043a\u0430): \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0438\u0437 ORDER BY.<\/p>\n<\/li>\n<li>\n<p>$next (\u0441\u0442\u0440\u043e\u043a\u0430): \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 page, \u0442\u043e \u0435\u0441\u0442\u044c &#8212; \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u044f\u0442\u0443\u044e.<\/p>\n<\/li>\n<\/ol>\n<p>\u0415\u0441\u043b\u0438 $next \u043f\u0443\u0441\u0442 (\u043d\u0443\u0436\u043d\u0430 \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430), \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0451\u043d \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 \u0434\u0432\u0443\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 &#8212; \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0432 SELECT \u0438 WHERE sql-\u0437\u0430\u043f\u0440\u043e\u0441\u0430:<\/p>\n<pre><code class=\"perl\">$VAR1 = 'concat(product.innovation,\\',\\',product.price,\\',\\',product.id)'; $VAR2 = 1;<\/code><\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c sql-\u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0438\u043c:<\/p>\n<pre><code class=\"sql\">SELECT product.id,    concat(product.innovation,product.price,product.id) as next FROM product WHERE  1 ... ORDER BY product.innovation DESC, product.price ASC, product.id ASC LIMIT 11<\/code><\/pre>\n<p>\u0422\u0443\u0442 LIMIT 11, \u0430 \u043d\u0435 10, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0442\u0430\u043a \u0436\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u043e\u0441\u043b\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <strong>next<\/strong> \u043a\u0430\u043a \u043c\u0435\u0442\u043a\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 <strong>2021-12-12,610,5000<\/strong>, \u043a\u0430\u043a \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 \u043d\u0430\u0448\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"perl\">$VAR1 = 'concat(product.innovation,\\',\\',product.price,\\',\\',product.id)'; $VAR2 = '(product.innovation &lt; 2021-12-12 OR product.innovation = 2021-12-12 AND product.price > 610 OR product.innovation = 2021-12-12 AND product.price = 610 AND product.id >= 5000)'; $VAR3 = [           'product.innovation',           'product.price',           'product.id'         ];<\/code><\/pre>\n<p>\u0418 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441 <strong>2021-12-12,610,5000<\/strong>:<\/p>\n<pre><code class=\"sql\">SELECT product.id,    concat(product.innovation,product.price,product.id) as next FROM product WHERE  (product.innovation &lt; 2021-12-12 OR product.innovation = 2021-12-12 AND product.price > 610 OR product.innovation = 2021-12-12 AND product.price = 610 AND product.id >= 5000) ... ORDER BY product.innovation DESC, product.price ASC, product.id ASC LIMIT 11<\/code><\/pre>\n<h2>\u0412\u044b\u0432\u043e\u0434\u044b<\/h2>\n<p>\u0422\u0430\u043a\u0430\u044f \u0441\u0445\u0435\u043c\u0430 <em>\u043c\u0435\u0442\u043e\u043a<\/em> \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u0432\u043c\u0435\u0441\u0442\u043e <em>\u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u0438<\/em> \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u043e\u0432. \u0422\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u043d\u043e\u0432\u043e\u0441\u0442\u043d\u043e\u0439 \u043b\u0438\u0441\u0442\u0438\u043d\u0433 \u0432 VK, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u041f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0434\u0430\u043b\u0451\u043a\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e \u043a\u0430\u0440\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (\u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0430\u0442\u044b, \u0442\u043e &#8212; \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044e). \u0417\u0430\u0442\u043e \u044d\u0442\u0438 \u043d\u0435\u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043a\u043e\u043c\u043f\u0435\u043d\u0441\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c \u043a \u043d\u0443\u0436\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0443.<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<ol>\n<li>\n<p>\u041f\u0435\u0439\u0434\u0436\u0438\u043d\u0433 \u043d\u0430 \u043c\u0435\u0442\u043a\u0430\u0445 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0435 \u043a\u043d\u0438\u0433 \/ <a href=\"https:\/\/kosmobook.ru\/?next=2022-01-30+00:00:00,1567030\" rel=\"noopener noreferrer nofollow\">https:\/\/kosmobook.ru\/?next=2022-01-30+00:00:00,1567030<\/a>.<\/p>\n<\/li>\n<li>\n<p>\u041b\u0438\u0441\u0442\u0438\u043d\u0433 \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439 \u0412\u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0435 \/ <a href=\"https:\/\/vk.com\/feed\" rel=\"noopener noreferrer nofollow\">https:\/\/vk.com\/feed<\/a>.<\/p>\n<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/674714\/\"> https:\/\/habr.com\/ru\/post\/674714\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-335280","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/335280","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=335280"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/335280\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=335280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=335280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=335280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}