0

Hello I want to get select query with send row record number

 $row = 3;
 SELECT FROM clients WHERE ROW()=$row ORDER BY ID DESC 

it is possible ? How can i do that ?

SwiftDeveloper
  • 7,244
  • 14
  • 56
  • 85

3 Answers3

4

If you want the third row, use offset/limit:

select *
from clients
order by id
offset 2
limit 1;

Note that that offset 0 gets the first record, so offset 2 would be the third record.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
0

You need to use LIMIT instead of WHERE

If you want get a row with N position, you can try this:

SELECT * FROM clients LIMIT N-1,1

So if you want get third row you need to use something like this:

SELECT * FROM clients LIMIT 2,1
semanser
  • 2,310
  • 2
  • 15
  • 33
0

This is what i would do.. entry_id is unique and 1 = first row, 2 = second row, etc..

entry_id is set as primary index and auto increase..

entry_id | what | ever | records
1 | a | b | c
2 | a | b | c
3 | b | c | a
4 | a | b | c
5 | a | b | c

$row = 3;

Select * From clients Where entry_id = $row

returns third row, 3, b, c, a

user2267175
  • 595
  • 5
  • 14