How to COUNT rows when they have a COUNT in them

2004-06-14 Thread Dave Torr
Probably simple but I can't figure it out! THe manual section 3.3.4.8 has the example SELECT owner, COUNT(*) FROM pet GROUP BY owner which is fine. Now what I want to do is count the number of rows this returns. Actually of course this is trivial - I can just count how many owners there are. Wha

Re: How to COUNT rows when they have a COUNT in them

2004-06-14 Thread Dave Torr
Thanks - this did not work for me as I am on 4.0.17 - presumably this works on 4.1 (seems to need the SubQuery feature)? If so I will upgrade immediately! From: Yayati Kasralikar <[EMAIL PROTECTED]> To: Dave Torr <[EMAIL PROTECTED]> CC: [EMAIL PROTECTED] Subject: Re: How to COU

Error 1250 Table from one of the SELECT's cannot be used in global ORDER clause

2004-06-14 Thread Dave Torr
I am getting the above error (the number is wrong - manual says this is 1249) on a statement of the form (SELECT species_table.species_id,count(*) as c FROM species_table INNER JOIN checklist_table USING (species_id,subspecies_id,name_id) GROUP BY species_id,source HAVING c=1) UNION (SELECT spe

Re: How to COUNT rows when they have a COUNT in them

2004-06-15 Thread Dave Torr
Thanks - that is basically what I used to do (it works fine now on 4.1.2) but it was very slow as there are a LOT of rows and this method returned all of them. From: Garth Webb <[EMAIL PROTECTED]> To: Dave Torr <[EMAIL PROTECTED]> CC: [EMAIL PROTECTED] Subject: Re: How to COUNT ro

Re: Error 1250 Table from one of the SELECT's cannot be used in global ORDER clause

2004-06-15 Thread Dave Torr
Unfortunately species_id is a column I am using for joining so I need the fully qualified name both in the SELECT and the ORDER BY. Anyway - I have just installed 40.17 on an old PC and found this statement works on 4.0.17, so it is clearly a "feature" of 4.1.2 and I will report it Thanks

Re: Error 1250 Table from one of the SELECT's cannot be used in global ORDER clause

2004-06-16 Thread Dave Torr
Don't follow your question - you suggested I use the column name (with no table name) as the ORDER BY. I said I can;t do this because I join on that column name - this means any references to it MUST be qualified with a table name. Anyway - reported this as a 4.1.2 bug (on the grounds that it u

Re: Error 1250 Table from one of the SELECT's cannot be used in global ORDER clause

2004-06-16 Thread Dave Torr
joining) the UNION just uses the (unqualified) column name to name the resulting table. Makes sense but not obvious! THanks to all who replied! From: [EMAIL PROTECTED] To: "Dave Torr" <[EMAIL PROTECTED]> CC: [EMAIL PROTECTED],[EMAIL PROTECTED] Subject: Re: Error 1250 Table