0

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??

3
  • Using ORDER BY (to ensure that your'e checking the entries in the ame order as you show here) and LIMIT (to specify which entry you want and how many you want) Commented Jun 4, 2016 at 14:15
  • What's the case between? Commented Jun 4, 2016 at 14:16
  • 1
    Why do you want to do this? Whats wrong with a where clause? Commented Jun 4, 2016 at 14:19

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

2 Comments

Maybe some ORDER BY should be added?
this code SELECT * FROM your_table LIMIT 4,1 is working ...but how to use ORDER BY in this code ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.