简体   繁体   English

显示最新查询结果

[英]display most recent query result

i have a query that i use to count the number of rows as a result, but i would also like to print out the most recent row of that query, in a view, but only that recent query instead of the whole array 我有一个查询,我用它来计算结果的行数,但我也想在视图中打印出该查询的最新行,但只打印该最近查询而不是整个数组

basically i use this query, then run a count to display the amount of rows which is a count i display, but i also want to display the latest date, location, and code, it can only get it to display all 基本上我使用此查询,然后运行一个计数以显示行数,这是我显示的计数,但是我也想显示最新的日期,位置和代码,它只能使它显示全部

2 options... 2个选项...

Select * from table order by primary_key desc;

count the results and print the first (most recent) row 计算结果并打印第一(最新)行

or run two separate queries... 或运行两个单独的查询...

select count(primary_key) as num_rows from table;
select * from table order by primary_key desc limit 1;

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

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