How to range ID from 1 to 5 and 10 to 6 in one SQL statement | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to range ID from 1 to 5 and 10 to 6 in one SQL statement

6th Sep 2021, 11:43 AM
Saleh Ismayilov
Saleh Ismayilov - avatar
7 Answers
+ 3
Answer to Is it possible to reverse ID (primary) in the database with auto increment so that it will always make the newest row's ID 1 automatically? by Mark Twaine https://www.quora.com/Is-it-possible-to-reverse-ID-primary-in-the-database-with-auto-increment-so-that-it-will-always-make-the-newest-rows-ID-1-automatically/answer/Mark-Twaine?ch=15&oid=42922425&share=3c4f9dce&srid=u79FBS&target_type=answer
6th Sep 2021, 12:08 PM
Rupali Haldiya
Rupali Haldiya - avatar
+ 2
Maybe he wants a result like this 1, 2, 3, 4, 5, 10, 9, 8, 7, 6 I honestly don't know if it's possible without subqueries
6th Sep 2021, 11:55 AM
Tim
Tim - avatar
+ 2
Rupali Thanks so much 🙏
6th Sep 2021, 12:12 PM
Saleh Ismayilov
Saleh Ismayilov - avatar
+ 2
You're welcome :)
6th Sep 2021, 12:31 PM
Rupali Haldiya
Rupali Haldiya - avatar
+ 1
SELECT columnName FROM tableName WHERE id >= 1 && id <= 5 SELECT columnName FROM tableName WHERE id <= 10 && id >= 6
6th Sep 2021, 11:54 AM
Rupali Haldiya
Rupali Haldiya - avatar
+ 1
Yes Nick I need result as you said
6th Sep 2021, 11:59 AM
Saleh Ismayilov
Saleh Ismayilov - avatar
+ 1
Im writing in SSMS
6th Sep 2021, 1:08 PM
Saleh Ismayilov
Saleh Ismayilov - avatar