Reputation: 4693
if i had 10 rows which fits this description on mysql
SELECT id, nav, img
FROM mytable
WHERE id='$id'
ORDER BY pageDisplayNum ASC;
pageDisplayNum
may not be in numeric order, meaning 1, 2, 5, 10, 16, 22 etc...
q: how can i choose the 3rd or 6th item from this list
the index number would be coming in from php as a variable
i read about TOP but this didnt work either
SELECT TOP $num
id, nav, img
FROM mytable
WHERE id='$id'
ORDER BY pageDisplayNum ASC;
Upvotes: 1
Views: 1275
Reputation: 2318
This for 7th item
SELECT id, nav, img
FROM mytable
WHERE id='$id'
ORDER BY pageDisplayNum ASC;
LIMIT 6,1
You can add LIMIT offset,row_count
query
Upvotes: 2
Reputation: 8948
You can use LIMIT <offset>, <#rows>
To select the row you want:
SELECT id, nav, img
FROM mytable
WHERE id='$id'
ORDER BY pageDisplayNum ASC
LIMIT 2, 1
Upvotes: 1