Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql:获取带有条件的字段的最后一个插入值的最佳方法是什么_Mysql - Fatal编程技术网

Mysql:获取带有条件的字段的最后一个插入值的最佳方法是什么

Mysql:获取带有条件的字段的最后一个插入值的最佳方法是什么,mysql,Mysql,获取带条件字段的最后插入值的最佳方法是什么。下面是我的代码。可以吗 SELECT c.field_chapter_value FROM content_type_story c INNER JOIN term_node t WHERE t.tid = ? AND c.nid=t.nid ORDER BY c.field_chapter_value DESC LIMIT 1 你不能结合加入和在哪里;使用ON子句: SELECT c.field_chapter_value FROM conten

获取带条件字段的最后插入值的最佳方法是什么。下面是我的代码。可以吗

SELECT c.field_chapter_value
FROM content_type_story c
INNER JOIN term_node t
WHERE t.tid = ? 
AND c.nid=t.nid
ORDER BY c.field_chapter_value DESC
LIMIT 1

你不能结合加入和在哪里;使用ON子句:

SELECT c.field_chapter_value
FROM content_type_story c
INNER JOIN term_node t ON c.nid = t.nid
WHERE t.tid = ? 
ORDER BY c.field_chapter_value DESC
LIMIT 1

您可以按DESC订购此列,前提是新记录的id更高(正如Bohemian所建议的那样,使用连接修复)


我们该怎么说呢?你几乎不提供任何信息。
SELECT c.field_chapter_value
FROM content_type_story c
INNER JOIN term_node t ON c.nid = t.nid
ORDER BY t.tid DESC, c.field_chapter_value DESC
LIMIT 1