I have a database table (crane_tbl)
cf_did cf_firstname cf_comment cf_cranetype
1 Alexy tfhgfnjh 2,3
2 Thomas fdghfgh 11,6,3
3 Thomas cgjkjhl 5,6,11,3
4 Thomasxc cgjkjhl 1,6,9,4
5 Thomaseg fdghgh 11,12,3
6 Thomasm fsgdfgbd 11,6,3
7 Thomabs dgtrty 7,9,11
8 Rdgfghfdg bfdhh 1,3,4
9 Gngfdytyt eertret 1,6,3
10 Dvbgfj hfdhhyrtyr 6,3
how to get 5th row values from this table using mysql query without where condition and don't specify any table field name??
You can use this query:
SELECT * FROM your_table ORDER BY column_number LIMIT 4,1
but think about situation, when you table will change.
Tables do not have a fifth row, because they represent unordered sets. You need a column to specify the ordering.
In this case, I presume you mean by the first column. Then you can get the fifth -- based on this column -- by using limit
and offset
:
select t.*
from t
order by cf_did
limit 1 offset 4;
This can also be written as limit 4, 1
.
offset
starts counting at 0 for the first row, so it really means the number of rows to skip.
Also, if you have an index on cf_did
(which is true if it is declared as the primary key), MySQL does not actually do a sort.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.