Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. SELECT id, x
  2. FROM (
  3. SELECT id, x
  4. FROM test
  5. WHERE x='y'
  6. LIMIT 1
  7. ) t1
  8. UNION ALL
  9. SELECT id, x
  10. FROM (
  11. SELECT id, x
  12. FROM test
  13. ORDER BY id DESC
  14. LIMIT 5
  15. ) t2;
  16.  
  17. # Или так
  18.  
  19. (SELECT id, x
  20. FROM test
  21. WHERE x='y'
  22. LIMIT 1)
  23. UNION ALL
  24. SELECT id, x
  25. FROM (
  26. SELECT id, x
  27. FROM test
  28. ORDER BY id DESC
  29. LIMIT 5
  30. ) t2;
  31.  
  32. # Или вот так
  33.  
  34. (SELECT id, x
  35. FROM test
  36. WHERE x='y'
  37. LIMIT 1)
  38. UNION ALL
  39. (
  40. SELECT id, x
  41. FROM test
  42. ORDER BY id DESC
  43. LIMIT 5
  44. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement