简体   繁体   English

无法使用限制从数据库中选择数据

[英]Can not use limit for select data from database

I use PHP MySQL select data like this with no error. 我使用PHP MySQL这样选择数据,没有错误。

$sql = "SELECT pd_id, pd_name, pd_price, pd_qty 
        FROM tbl_product ORDER BY pd_id DESC";

I want to select only 6 row. 我只选择6行。 So, I edit code like this. 所以,我这样编辑代码。

$sql = "SELECT pd_id, pd_name, pd_price, pd_qty 
        FROM tbl_product ORDER BY pd_id DESC LIMIT 6";

Then , It show error like this. 然后,它显示这样的错误。

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LIMIT 0, 6' at line 2

How to select data 6 row from MySQL 如何从MySQL选择数据6行

Try this one 试试这个

$sql = "SELECT pd_id, pd_name, pd_price, pd_qty 
        FROM tbl_product ORDER BY pd_id DESC LIMIT 0, 6 ";
SELECT TYPE FROM stuff ORDER BY STUFF_ID DESC LIMIT 6

用上面使用的列替换查询

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM