我想要列第一个单元格值,如何选择它有帮助我。在mysql中存在第一个函数。
答案 0 :(得分:1)
数据库表中的行大多数没有排序。要在结果中获得订单,请使用ORDER BY
子句。要仅获取此有序集的第一行,可以使用LIMIT
子句。所以你的查询将是:
SELECT
column1
FROM
yourtable
ORDER BY
whatever_column_is_appropriate
LIMIT 1
SELECT的语法乍一看可能有点压倒性:
SELECT
[ALL | DISTINCT | DISTINCTROW ]
[HIGH_PRIORITY]
[STRAIGHT_JOIN]
[SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
[SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS]
select_expr [, select_expr ...]
[FROM table_references
[PARTITION partition_list]
[WHERE where_condition]
[GROUP BY {col_name | expr | position}
[ASC | DESC], ... [WITH ROLLUP]]
[HAVING where_condition]
[ORDER BY {col_name | expr | position}
[ASC | DESC], ...]
[LIMIT {[offset,] row_count | row_count OFFSET offset}]
...
最好通过一些数据库教程来掌握SQL。