Re: [SQL] SQL Syntax / Logic question

2001-10-08 Thread Thurstan R. McDougle
To help you understand SQL I should point out that your version would work (assuming only 1 school per person) if you just left the friends out of the FROMs for the sub-selects:- select frienda, friendb from friends where (select schools.school from schools as schoolsa where friends.frienda = sc

Re: [SQL] A simple join question that may stump you

2001-09-26 Thread Thurstan R. McDougle
How about:- SELECT id FROM (a LEFT JOIN b WHERE a.flag=b.flag) GROUP BY id HAVING ((COUNT(*)=COUNT(b.flag)) AND (COUNT(*)=(SELECT COUNT(*) FROM b AS b_cnt))); This relys on COUNT(field) not counting NULLs, and that NULL is what the LEFT JOIN returns for an absent b.flag:-

Re: [SQL] Selecting latest value II

2001-09-21 Thread Thurstan R. McDougle
Hi back Carl van Tast wrote: > > Hi, Thurstan > > On Thu, 20 Sep 2001 17:30:46 +0100, "Thurstan R. McDougle" > <[EMAIL PROTECTED]> wrote: > > > [...] > >Carl van Tast had 2 good methods as follows > > > >SELECT userid, va

Re: [SQL] Selecting latest value II

2001-09-20 Thread Thurstan R. McDougle
Look at his table structure, you will see a timestamp. His request can be rephrased as "The val field from the latest record for each userid in turn. Carl van Tast had 2 good methods as follows SELECT userid, val FROM tbl WHERE NOT EXISTS (SELECT * FROM tbl AS t2 WHERE tbl.us

Re: [SQL] table restruct...

2001-09-20 Thread Thurstan R. McDougle
"David M. Richter" wrote: > snip... > Yes I have to do . Now I solved that problem with rename the original > table study to _study > then create the new right structured table study , Insert into study > (chilioid,...,...) SELECT * FROM _study; > Ok not elegant but it works. > > Another questio

[SQL] Re: GRANT ALL ON TO GROUP failure

2001-08-30 Thread Thurstan R. McDougle
user is an SQL reserved word, use 'user' instead. You might like to have a look at the list of reserved words at http://www.postgresql.org/idocs/index.php?sql-keywords-appendix.html Jari Aalto+usenet wrote: > > [Please keep CC] > > Can anyone suggest, what is wrong with the following