|
Posted by Tom on 05/24/07 17:36
<MissHex@gmail.com> wrote in message
news:1179993704.285514.217600@p77g2000hsh.googlegroups.com...
> Hello everyone,
>
> am building a housing system
> and i want to be able to seach the data base for empty rooms then
> assign no more than 2 students in each room
>
> i have a table Student that contains Student ID
> and a table Room that contains the room ID
> i built another table that contains the roomID and the StudentID
> but how can i limit the entries to the rooms to make no more than two?
> and also search if for empty spaces?
>
> thank you very much in advanced
>
> regards,
>
You can use "count" in your SQL query such as
SELECT count(RoomID), RoomID
FROM AnotherTable
WHERE StudentID IS NOT NULL
AND RoomID IS NOT NULL
GROUP BY RoomID;
That would at least give you the results, but would need to control the
limit in your PHP code.
Tom
--
Basic Accounts $5.95 / mo. or $39.95 / yr.
http://newsguy.com/overview.htm
[Back to original message]
|