[英]how to display the smallest data in phpmyadmin
I need help to get the solution for this condition. 我需要帮助以获取针对这种情况的解决方案。 This is my query : 这是我的查询:
SELECT a.idbarang, a.nama,b.stokbagus, a.hargaJual , b.exp
FROM barang a
LEFT JOIN detail_barang b on a.idbarang = b.idbarang
WHERE a.status = '1'
the result : 结果 :
idbarang nama stokbagus hargaJual exp
-------- ---------------- --------- --------- ----------
33001 Pepsi Can 330 Ml 30 900 2015-06-17
21001 Cheetos 10gr 30 900 2015-12-19
21001 Cheetos 10gr 25 900 2014-12-07
how to display one cheetos that have the smallest 'exp'. 如何显示具有最小“ exp”值的奇多。 I want to display 我想展示
idbarang nama stokbagus hargaJual exp
-------- ---------------- --------- --------- ----------
33001 Pepsi Can 330 Ml 30 900 2015-06-17
21001 Cheetos 10gr 25 900 2014-12-07
You can order by exp and set the limit to 1, that way only the lowest exp will be shown. 您可以按exp排序并将极限设置为1,这样只会显示最低的exp。 It would look like this: 它看起来像这样:
SELECT a.idbarang, a.nama,b.stokbagus, a.hargaJual , b.exp FROM barang a LEFT JOIN detail_barang b on a.idbarang = b.idbarang 从barang选择a.idbarang,a.nama,b.stokbagus,a.hargaJual,b.exp a.idbarang = b.idbarang上的LEFT JOIN detail_barang b
WHERE a.status = '1' ORDER BY b.exp LIMIT 1; 在a.status ='1'的情况下按b.exp LIMIT 1排序;
If you want to display the smallest exp
for each nama
, you need to use GROUP BY
. 如果要显示每个nama
的最小exp
,则需要使用GROUP BY
。 Try this: 尝试这个:
SELECT a.idbarang, a.nama,b .stokbagus, a.hargaJual, MIN(b.exp)
FROM barang a
LEFT JOIN detail_barang b ON a.idbarang = b.idbarang
WHERE a.status = '1'
GROUP BY a.idbarang
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.