var isMobile = {
Android: function () {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function () {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function () {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function () {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function () {
return navigator.userAgent.match(/IEMobile/i);
},
any: function () {
return (
isMobile.Android()
|| isMobile.BlackBerry()
|| isMobile.iOS()
|| isMobile.Opera()
|| isMobile.Windows()
);
}
};
CREATE TABLE tmp (
id INT,
color VARCHAR(255)
);
INSERT INTO tmp
(id, color)
VALUES
(1, 'зеленый'),
(2, 'красный'),
(3, 'синий'),
(4, 'белый')
;
SELECT id, color FROM (
SELECT
id,
@join_pk_1:=@join_pk_1 + 1 as join_pk
FROM tmp, (select @join_pk_1:=0) as join_pk_1
ORDER BY id DESC
) as tbl1
LEFT JOIN (
SELECT
color,
@join_pk_2:=@join_pk_2 + 1 as join_pk
FROM tmp, (select @join_pk_2:=0) as join_pk_2
) as tbl2
ON tbl1.join_pk = tbl2.join_pk
id color
4 зеленый
3 красный
2 синий
1 белый