Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Fetch Consecutive Records

Author  Topic 

asadmoin
Starting Member

1 Post

Posted - 2005-07-24 : 18:25:03
Hello!

I am trying to add seating to a ticket purchase application. Seats are assigned according to Section, Row and Seat Number. So for example, a sample ticket would have a Section: A, Row: 2, Seat:4.

The problem is that I want to be able to automatically assign consecutive seats if a customer purchases more than one ticket. I have created a database table with 4 fields:

(ID, Section, Row, Seat)
1 A 1 1
2 A 1 2
3 A 1 3
4 A 2 1
5 A 2 2
6 A 2 3
7 B 1 1
8 B 1 2
9 B 2 1
10 B 2 2

I want to be able to fetch only those seats that are beside each other. Like with IDs: 1,2,3 OR 7,8 and NOT with IDs: 3,4 OR 6,7
What would be the query that would perform this kind of task.

Also would it be better to have a different table design that would help achieve the desired result?

Thanks!

Asad

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-07-25 : 00:50:10
Something similar to this
http://sqlteam.com/forums/topic.asp?TOPIC_ID=51195

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -