select id,date,creator,max(date) as m FROM rooms_bids WHERE date > "1517427936" and date < "1517428356" GROUP BY creator
CREATE TABLE `act` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`date` int(10) unsigned NOT NULL,
`creator` int(10) unsigned NOT NULL,
`value` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8
CREATE TABLE `users` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`invited_by_id` int(11) unsigned DEFAULT NULL,
`creator_id` int(11) unsigned DEFAULT NULL,
`name` varchar(128) NOT NULL,
`lname` varchar(128) NOT NULL,
`email` varchar(128) NOT NULL,
`phone` varchar(128) NOT NULL,
`ava_file` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8
SELECT SQL_CALC_FOUND_ROWS
*
FROM
(SELECT
*,
(
SELECT
offers_meta.meta_value
FROM
offers_meta
WHERE
offers_meta.meta_name = 'nacenka'
AND offers.offer_id = offers_meta.offer_id
ORDER BY offers_meta.id
LIMIT 1
) AS lastprice
FROM
offers
WHERE
offers.hold < 1500817610
AND offers.status = 'on sale'
) zz
WHERE
zz.lastprice IS NOT NULL
OR zz.master IN (0,4)
ORDER BY zz.price DESC
LIMIT 0, 25
SELECT SQL_CALC_FOUND_ROWS *
FROM offers
LEFT OUTER JOIN (SELECT * FROM `offers_meta` ORDER BY `offers_meta`.`id` DESC) offers_meta
ON offers.offer_id = offers_meta.offer_id
WHERE (offers_meta.offer_id IS NOT NULL AND offers_meta.meta_name = 'nacenka') or (offers.master = 0 or offers.master = {$_SESSION['user_id']})
$sort and offers.hold < $datenow and offers.status = 'on sale'
GROUP BY offers.offer_id
ORDER BY master DESC
$limit
SELECT SQL_CALC_FOUND_ROWS *,
(SELECT offers_meta.meta_value FROM offers_meta WHERE offers_meta.meta_name = 'nacenka' AND offers.offer_id = offers_meta.offer_id ORDER BY offers_meta.id LIMIT 1) AS lastprice
FROM offers WHERE
(
offers.master = 0 OR offers.master = {$_SESSION['user_id']}
) AND (lastprice != NULL)
AND
offers.hold < $datenow
AND offers.status = 'on sale'
ORDER BY offers.price DESC $limit
SELECT SQL_CALC_FOUND_ROWS
*,
(
SELECT
offers_meta.meta_value
FROM
offers_meta
WHERE
offers_meta.meta_name = 'nacenka' AND offers.offer_id = offers_meta.offer_id
ORDER BY
offers_meta.id
LIMIT 1
) AS lastprice
FROM
offers
WHERE
(lastprice IS NOT NULL) or (
offers.master = 0 OR offers.master = 4
) AND offers.hold < 1500817610 AND offers.status = 'on sale'
ORDER BY
offers.price
DESC
LIMIT 0, 25