gpt4 book ai didi

php - 检索 productcode 字段的最后一个 id 值

转载 作者:行者123 更新时间:2023-11-29 05:10:06 24 4
gpt4 key购买 nike

我无法检索最后一个 id 值 asscoaited productcode 字段

enter image description here

我尝试了以下方法来检索 ProductCode 的最大 ID

select MAX(id) from code ORDER by productcode desc;

我得到的“id”为 25,它没有与之关联的“productcode”。

select MAX(id) from code ORDER by id where productcode is NOT Null;

我收到相同的语法错误

我只需要与产品代码关联的 max(id) 即 ..,id= 23;

最佳答案

select MAX(id) from code WHERE CHAR_LENGTH(ProductCode)>=1 ORDER by ProductCodedesc;

会起作用。您还可以对空字符串进行条件测试。

希望对您有所帮助!如果您还需要什么,请告诉我

注意:在这种情况下检查 null 也会导致误报,因为您的空字段值似乎是字面上的空字符串..而不是 null 值

limit 确实没有必要。

关于php - 检索 productcode 字段的最后一个 id 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40868187/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com