Guest User

Untitled

a guest
Aug 2nd, 2012
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. MySQL Select and LIMIT
  2. id ip
  3. 1 127.0.0.1
  4. 2 127.0.0.1
  5. 3 127.0.0.1
  6. 4 192.168.2.2
  7. 5 192.168.70.1
  8. 6 217.11.24.65
  9.  
  10. SELECT id FROM ips LIMIT 3 // returns 1,2,3 but i want 1,2,3,4,5
  11.  
  12. SELECT id
  13. FROM ips
  14. WHERE ip IN (SELECT DISTINCT ip FROM ips ORDER BY id LIMIT 3)
  15.  
  16. SELECT id
  17. FROM ips
  18. 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