midnite Posted March 26, 2007 Share Posted March 26, 2007 excuse me, let's say i have totally 10 seats numbered from 1 to 10 and people are randomly sitting on them.Yet, currently there are only 3 people and i have the table recorded: +------+------+| ppl | seat |+------+------+| andy | 7 || jen | 4 || amy | 3 |+------+------+ and now i would like to list out the blank seats +------------+| blank_seat |+------------+| 1 || 2 || 5 || 6 || 8 || 9 || 10 |+------------+ the idea is to list out the elements that the current table DO NOT have and its seat id is less than 10. i got the idea but don't know how to write the query. Thanks for helping in advance :] Link to comment Share on other sites More sharing options...
Yahweh Posted March 26, 2007 Share Posted March 26, 2007 I think it would be nice if SQL had a syntax that allows you to say "Select incrementer as seats_available from some_table where incrementer between 1 and 10".I don't think you can actually get SQL to select a dynamic range like that, unless you have a table that lists all the possible seats. You probably need to handle your output by serverside code, by running through a loop of occupied seats and displaying only the unfilled seats. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now