Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MySQL Select and LIMIT
- id ip
- 1 127.0.0.1
- 2 127.0.0.1
- 3 127.0.0.1
- 4 192.168.2.2
- 5 192.168.70.1
- 6 217.11.24.65
- SELECT id FROM ips LIMIT 3 // returns 1,2,3 but i want 1,2,3,4,5
- SELECT id
- FROM ips
- WHERE ip IN (SELECT DISTINCT ip FROM ips ORDER BY id LIMIT 3)
- SELECT id
- FROM ips
- WHERE ip IN (SELECT * FROM (SELECT DISTINCT ip FROM ips ORDER BY id LIMIT 3) alias)
Advertisement
Add Comment
Please, Sign In to add comment