skip to Main Content
1|Health & Fitness
2|Cardiovascular
3|General Fitness
4|Pilates
5|Technology
6|Artificial Intelligence
7|Advance Learning Machines
8|Virtual and Augmented Reality.

this is data in my table.

I want to get data in between Health & Fitness & Technology

2

Answers


  1. Try a query like this

       SELECT * FROM topics
        where
          id >= ( SELECT id from topics WHERE name = 'Health & Fitness')
        AND
          id <= ( SELECT id from topics WHERE name = 'Technology')
        order by id;
    

    query with auto min / max

       SELECT * FROM topics
        where
          id >= ( SELECT min(id) from topics WHERE name IN('Health & Fitness','Technology'))
        AND
          id <= ( SELECT max(id) from topics WHERE name IN('Health & Fitness','Technology'))
        order by id;
    
    Login or Signup to reply.
  2. If there are no other fields in the table, then this task can not be solved with some simple syntax. The problem is that data in a relation (table) is unsorted and in general, if you run simple select statements like

    select * from  topics 
    

    you may get records in any order.

    Whereas, if you have a field, by which you can sort or set a range, then you can try the above solution by Bernd Buffen.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search