sql or my sql query


hi,

in my database  i have the two tables...

1)programs                                2)reserved


in the programs...two fields 1)program id           2)maxseats................these details wil be entered by admin

in the reserved table  two fileds ..1)PRogramid        2)status


my requirement is .. i need the available seats..means

if any body is intersted in  any program...they wil select the program...then status becomes approved(1)..

then i need the o/p as available seats ..means if any body selects the program...then the maxseats should be decremented by 1...o/p should be the remaing seats..

0
rameshgoudd
11/30/2007 6:17:25 AM
📁 asp.net.sql-datasource
📃 29906 articles.
⭐ 0 followers.

💬 1 Replies
👁️‍🗨️ 1541 Views

Eh?

To get the number of seats for a program:

SELECT maxseats
FROM programs
WHERE program_id = @ProgramId

And you might be needing a couple of UPDATE queries for the other logic:

UPDATE reserved_table
SET status = 'Approved'
WHERE program_id = @ProgramId

UPDATE programs
SET maxseats = maxseats - 1
WHERE program_id = @ProgramId

 


Coolest Bananas
0
lee
11/30/2007 10:02:59 AM