Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql - sql select to start from id [closed]

Tags:

php

mysql

How can I start a SQL query from a specific ID...

id | name  |
------------
1  | Joe   |

2  | Craig |

3  | Shawn |

4  | Ryan  |

5  | Seth  |

I want to start from ID 3

$strSQL = "SELECT * FROM table_name WHERE id >= 3";

Thanks for any help!

like image 440
Andrei Avatar asked Dec 08 '22 10:12

Andrei


2 Answers

use also ORDER BY for right order

SELECT * FROM table_name WHERE id >= 3 ORDER BY id ASC
like image 180
Victor Bocharsky Avatar answered Dec 11 '22 07:12

Victor Bocharsky


use order by like this

$strSQL = "SELECT * FROM table_name WHERE id>=3 ORDERT BY id;
like image 44
Satish Sharma Avatar answered Dec 11 '22 07:12

Satish Sharma