按查询排序的结果显示错误


Result of order by query showing wrong

我正在调用按主id排序的sql查询。

例如。"从按product_id DESC排序的产品中选择product_id"

这个查询给了我所有的产品列表,但不是按降序排列的,
它让我喜欢
product_id
1033
599
587
167
1233
1224
像这样
每当我使用分页时,它会在第二页调用中给我更大的数字
有人能告诉我为什么会发生这种事吗?

如果添加WHERE关键字,则必须遵循至少一个条件。把它拿出来,它应该会起作用。

您的查询应该是这样的:select product_id from products order by product_id DESC

如果要添加一些条件,则必须在where column_name=criteria 之后指定

如果您使用where clause,则必须至少给出匹配条件。如果您没有任何匹配do not use where clause:的条件

select product_id from products order by product_id DESC

如果您想使用where子句,请执行以下操作:

 select product_id from products where column_name='value for condition' order by product_id DESC