我试图在参考时订购以下结果。使用Order by和desc limit 100.有人可以帮助我放置它。
$stm = $pdo->prepare("SELECT `reference`, SUM( `stockdifference` ) AS 'stockdifference'
FROM `results1`
WHERE `datum` BETWEEN '".$oldDate."' AND '".$newDate."' AND `reference` = '".$stm[0]."'");
答案 0 :(得分:0)
订购SQL查询很简单。
Select *
FROM table
Where column=condition
ORDER BY column desc/asc
Limit
答案 1 :(得分:-1)
尝试:
<?php
$stm = $pdo->prepare("SELECT `reference`, SUM( `stockdifference` ) AS 'stockdifference'
FROM `results1`
WHERE `datum` BETWEEN '".$oldDate."' AND '".$newDate."' AND `reference` = '".$stm[0]."'
Order by 'your column',
'your column' desc,
limit 100
");