I have a table:
name count
Name 1 1
Name 2 1
Name 3 1
Name 4 1
Name 5 2
Name 6 2
If I select Name 2 (count = 1), how do I select the next and previous item (Name 3, Name 1)? After all values are the same.
How to solve my problem?
If you want a single query then I think this might be the query you are loooking for.
select * from table where coun=(select coun from table where name='name1')
and name!='name1'
I just rename count column to coun as count is an agg. function in mysql. hope it works for you..