[SQL] Tough Problem -- Record Checkouts
Imagine a library of books. Each book is a record. The library is the table. A user may check out a book and the shelf space it once occupied will store the minute that the user checked the book out. Every 5 minutes, a magical librarian walks through the library and when a book has been checked out longer than 15 minutes, she has the power to zap it back out of the user's hands and put it back on the shelf for someone else. How do you efficiently achieve this in a WHERE clause in SQL? For instance, here's a table of several minute columns. CO, in this case, is the checked out minute. N, in this case, is the current minute. This translates to, "If the CO = x, and N is within this range, then clear the CO column." CO| N --+--- 0 | 15-59 1 | 0, 16-59 2 | 0-1, 17-59 15| 0-14, 30-59 16| 0-15, 31-59 30| 0-29, 45-59 31| 0-30, 46-59 45| 0-44 46| 1-45 59| 14-58 This becomes some kind of UPDATE statement with a complex WHERE clause. ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
[SQL] Re: [GENERAL] Re: MySQLs Describe emulator!
* Boulat Khakimov <[EMAIL PROTECTED]> [010306 07:24] wrote: > > Karel Zak wrote: > > > On Tue, Mar 06, 2001 at 09:14:54AM -0500, Boulat Khakimov wrote: > > > Tom Lane wrote: > > > > > > > > Boulat Khakimov <[EMAIL PROTECTED]> writes: > > > > > Here is a nifty query I came up with > > > > > that provides a detailed information on any row of any table. > > > > > Something that is build into mySQL (DESC tablename fieldname) > > > > > but not into PG. > > > > > > > > Er, what's wrong with psql's "\d table" ? > > > > > > 2) as a programmer I need to be able to find out as much info as > > > possible about any given field > > >which is what "describe" for in mySQL. > > > > As a programmer you can see psql source and directly found how SQL > > query execute this tool. The PostgreSQL needn't non-standard statements > > like MySQL's SHOW, DESC -- the postgreSQL has system catalogs. FreeBSD has had some great successes because we're able to emulate Linux, perhaps something in contrib or even the base system could offer a MySQL compatibility module to help people ease into Postgresql from Mysql? -- -Alfred Perlstein - [[EMAIL PROTECTED]|[EMAIL PROTECTED]] ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly