Re: [SQL] showing multiple REFERENCE details of id fields in single query that share the same table

2005-09-14 Thread Thomas O'Connell
On Sep 14, 2005, at 8:11 PM, Ferindo Middleton Jr wrote: I have a table which has two id fields which REFERENCE data back at another table. It's setup like this: class_prerequisite_bindings(id SERIAL, class_id INTEGER REFERENCES classes(id), prerequisiteINTEGER REFERENCES class

[SQL] showing multiple REFERENCE details of id fields in single query that share the same table

2005-09-14 Thread Ferindo Middleton Jr
I have a table which has two id fields which REFERENCE data back at another table. It's setup like this: class_prerequisite_bindings(id SERIAL, class_id INTEGER REFERENCES classes(id), prerequisiteINTEGER REFERENCES classes(id)) The classes table is like this: classes(idSE

Re: [SQL] CREATE TEMPORARY TABLE ON COMMIT DROP

2005-09-14 Thread Tom Lane
Luis Sousa <[EMAIL PROTECTED]> writes: > But how can I create a table using a query and putting ON COMMIT DROP. You can't. Use INSERT ... SELECT to fill the table, instead. regards, tom lane ---(end of broadcast)--- TIP 1:

[SQL] CREATE TEMPORARY TABLE ON COMMIT DROP

2005-09-14 Thread Luis Sousa
Hi all, I'm tryng to write query that on commit drops the temporary table but I'm doing someting wrong. According do documentation, I can create a temporary table using this syntax: CREATE TEMP TABLE table_name AS SELECT * from table_select; or I can create a table like this: CREATE TEMP TAB

Re: [SQL] What should this query match?

2005-09-14 Thread Peter Eisentraut
Am Mittwoch, 14. September 2005 13:09 schrieb Joost Kraaijeveld: > Could you give me an example? I understand that the following query > returns all matches but I want everything smalle than the match If you need that then you will need to use two separate conditions, one for less-than and one fo

Re: [SQL] Need help with 'unique parents' constraint

2005-09-14 Thread Daryl Richter
Leif B. Kristensen wrote: On Sunday 11 September 2005 16:04, Greg Sabino Mullane wrote: Not just old-fashioned, it's the biological law! (among homo sapiens anyway). I'd approach this with a trigger, as you can do complex checks and get back nice customized error messages. A sample script foll

Re: [SQL] What should this query match?

2005-09-14 Thread Joost Kraaijeveld
On Wed, 2005-09-14 at 12:48 +0200, Peter Eisentraut wrote: > These queries should return the same answer if the query does not contain the > value 'Jan%' (or differently capitalized versions). I suspect that you are > actually attempting to use % as a wild card, but none of your queries use a

Re: [SQL] What should this query match?

2005-09-14 Thread Peter Eisentraut
Am Mittwoch, 14. September 2005 11:54 schrieb Joost Kraaijeveld: > Why do the following queries return the same count (may be related to > the first question) > > SELECT COUNT(*) FROM customers > WHERE lower(lastName) < lower('Jan%') > > SELECT COUNT(*) FROM customers > WHERE lower(lastName) <= low

[SQL] What should this query match?

2005-09-14 Thread Joost Kraaijeveld
Hi, Should the follwing query match a record with just "Jan" in the column (there are no nulls in the column and there are 2 records with only "Jan" in it) ? SELECT COUNT(*) FROM customers WHERE lower(lastName) < lower('Jan%') If so, and if the result of the previous question is "144660", sho