RE: Count Query question

2010-05-13 Thread webmaster
ifang -Original Message- From: Keith Clark [mailto:keithcl...@k-wbookworm.com] Sent: 13 May 2010 14:11 To: mysql@lists.mysql.com Subject: Re: Count Query question Bob, Here are a few rows of my data: 17462, 0, '0929998596', '/GraphicNovels/0929998596.jpg', '8.5000

Re: Count Query question

2010-05-13 Thread Keith Clark
Bob, Here are a few rows of my data: 17462, 0, '0929998596', '/GraphicNovels/0929998596.jpg', '8.5000', '2010-05-12 19:02:47', '2008-10-01 00:00:00', '2008-10-01 00:00:00', '0.50', 1, 1, 7429, 0, '1', 17461, 1, '1561481912', '/Cooking/1561481912.jpg', '3.', '2010-05-12 19:00:17', '2008-10-0

Re: Count Query question

2010-05-12 Thread Bob Cole
Kevin: I assumed the following data: products_id products_date_available products_quantity 11 2010-05-01 1 11 2010-05-02 0 11 2010-05-03 3 11 2010-05-04 3 11 2010-05-05 3 11 2010-05-06 1 11 2010-05-07 0 11 2010-05-08

Re: Count Query question

2010-05-12 Thread Keith Clark
Hi Bob, No, actually it does not. I'm looking for the count of items. From your query example I only get two rows. This table has over 2 1/2 years of daily sales data. Maybe I'm not stating my question correctly...h Thanks for responding though, greatly appreciated. Keith On Wed, 20

Re: Count Query question

2010-05-12 Thread Bob Cole
Keith: Does this work? SELECT products_date_available, COUNT(products_quantity) FROM products WHERE products_quantity > 0 GROUP BY products_date_available Hope this helps, Bob On May 12, 2010, at 3:06 PM, Keith Clark wrote: > On Wed, 2010-05-12 at 10:13 -0400, Keith Clark wrot

Re: Count Query question

2010-05-12 Thread Keith Clark
On Wed, 2010-05-12 at 10:13 -0400, Keith Clark wrote: > Chris, > > Here is my full table definition: > > CREATE TABLE `products` ( > `products_id` int(15) NOT NULL AUTO_INCREMENT, > `products_quantity` int(4) NOT NULL, > `products_model` varchar(15) NOT NULL DEFAULT '', > `products_image` var

Re: Count Query question

2010-05-12 Thread Keith Clark
Chris, Here is my full table definition: CREATE TABLE `products` ( `products_id` int(15) NOT NULL AUTO_INCREMENT, `products_quantity` int(4) NOT NULL, `products_model` varchar(15) NOT NULL DEFAULT '', `products_image` varchar(64) DEFAULT NULL, `products_price` decimal(15,4) DEFAULT NULL, `p

Re: Count Query question

2010-05-12 Thread Chris W
With out the table definitions, I'm not sure how anyone could help. Can you send the output of "show create table" for each of the tables involved in this query? Chris W Keith Clark wrote: I'm trying to produce a report that will tell me how many products were available with a Quantity>0 bef

Re: count children nodes

2010-02-17 Thread David Arroyo Menendez
Thanks! 2010/2/16 Peter Brawley > David, > > >I need count the messages don'tread in a thread. > > Have a look at the edge list examples at > http://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch20.html. > > PB > > - > > David Arroyo Menendez wrote: > > Hello, > > I've the next table s

Re: count children nodes

2010-02-16 Thread Peter Brawley
David, I need count the messages don'tread in a thread. Have a look at the edge list examples at http://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch20.html. PB - David Arroyo Menendez wrote: Hello, I've the next table structure: CREATE TABLE tx_cc20_mensajes ( uid int(11

RE: count children nodes

2010-02-16 Thread Gavin Towey
Trees can be complex in SQL; these articles will give some different ideas to handle it: http://hashmysql.org/index.php?title=Trees_and_hierarchical_data_in_SQL http://dev.mysql.com/tech-resources/articles/hierarchical-data.htm Regards, Gavin Towey -Original Message- From: David Arroyo M

Re: Count records in join

2009-12-16 Thread Miguel Vaz
essage- > >From: Miguel Vaz [mailto:pagong...@gmail.com] > >Sent: Wednesday, December 16, 2009 9:39 AM > >To: Johan De Meersman > >Cc: Gavin Towey; mysql@lists.mysql.com > >Subject: Re: Count records in join > > > >Thanks all for the feedback. Here's what i

RE: Count records in join

2009-12-16 Thread Jerry Schwartz
>-Original Message- >From: Miguel Vaz [mailto:pagong...@gmail.com] >Sent: Wednesday, December 16, 2009 9:39 AM >To: Johan De Meersman >Cc: Gavin Towey; mysql@lists.mysql.com >Subject: Re: Count records in join > >Thanks all for the feedback. Here's what i d

Re: Count records in join

2009-12-16 Thread Miguel Vaz
Thanks all for the feedback. Here's what i did: select p.id_prog,count(r.id_event) e from programas p left join(events r) on(p.id_prog=r.id_prog) group by r.id_event This gives me a list of all the distinct progs with a count of how many events on each. I then delete the empty ones. It would be

Re: Count records in join

2009-12-16 Thread Johan De Meersman
If the aim is purely to find the progs without events, it might be more efficient to use something like select * from progs where not exist (select id_prog from events where id_prog = progs.id_prog); My syntax might be off, check "not exists" documentation for more info. On Tue, Dec 15, 2009 at

RE: Count records in join

2009-12-15 Thread Gavin Towey
Hi Miguel, You'll need to use LEFT JOIN, that will show all records that match and a row in the second table will all values NULL where there is no match. Then you find all those rows that have no match in your WHERE clause. Regards, Gavin Towey -Original Message- From: Miguel Vaz [ma

Re: COUNT from 2 tables

2009-07-08 Thread b
On 07/08/2009 06:11 PM, Gary Smith wrote: Create a view or sub select, denormalizing the data and then group it. select month, sum(login) as num_logins, sum(download) as num_downloads from ( select monthname(s.created) as month_name , if(ifnull(s.id, 0)> 0, 1, 0) as login , if(ifnull(d.id, 0)>

RE: COUNT from 2 tables

2009-07-08 Thread Gary Smith
listed first (I could be wrong though -- chime in if you know the definitive answer please). Anyway, try this and see if it gets you closer. From: b [my...@logi.ca] Sent: Wednesday, July 08, 2009 12:55 PM To: mysql@lists.mysql.com Subject: Re: COUNT from 2

Re: COUNT from 2 tables

2009-07-08 Thread b
On 07/08/2009 03:33 PM, Gary Smith wrote: Off the top of my head, try this. SELECT MONTHNAME(s.created) AS month, sum(if(ifnull(s.id,0)> 0, 1, 0)) AS num_logins, sim(if(ifnull(d.id, 0)> 0, 1, 0)) AS num_downloads FROM sessions AS s LEFT JOIN downloads AS d ON d.session_id = s.id GROUP BY month

RE: COUNT from 2 tables

2009-07-08 Thread Gary Smith
Off the top of my head, try this. SELECT MONTHNAME(s.created) AS month, sum(if(ifnull(s.id,0) > 0, 1, 0)) AS num_logins, sim(if(ifnull(d.id, 0)> 0, 1, 0)) AS num_downloads FROM sessions AS s LEFT JOIN downloads AS d ON d.session_id = s.id GROUP BY month

Re: COUNT returned rows of a SELECT

2008-07-31 Thread Fish Kungfu
w in set (0.30 sec) CheersFish -Original Message- >From: Roy Lyseng <[EMAIL PROTECTED]> >Sent: Jul 31, 2008 9:41 AM >To: Fish Kungfu <[EMAIL PROTECTED]> >Subject: Re: COUNT returned rows of a SELECT > >Hi, > >generally you should be able to use the

Re: COUNT returned rows of a SELECT

2008-07-31 Thread Perrin Harkins
On Thu, Jul 31, 2008 at 8:00 AM, Fish Kungfu <[EMAIL PROTECTED]> wrote: > Ideally, I was hoping COUNT() could work like this, BUT it doesn't of > course: > > mysql> SELECT COUNT(SELECT aviName,MAX(dateTime) ,count(*) FROM > aviTrackerMain WHERE DATE(dateTime) LIKE CONCAT(DATE(NOW()),'%') GROUP > BY

RE: COUNT returned rows of a SELECT

2008-07-31 Thread Jerry Schwartz
>-Original Message- >From: Fish Kungfu [mailto:[EMAIL PROTECTED] >Sent: Thursday, July 31, 2008 12:41 AM >To: mysql@lists.mysql.com >Subject: COUNT returned rows of a SELECT > >Using MySQL commands only (not PHP's mysql_num_rows), is there a way to >COUNT the number of rows returned from a

Re: COUNT returned rows of a SELECT

2008-07-31 Thread Fish Kungfu
Thanks for trying guys, but that's still not quite what I'm looking for. All I really want is the total number of rows returned for the query result. For example, my the SELECT that Ananda suggested returns this: mysql> SELECT aviName,MAX(dateTime) ,count(*) FROM aviTrackerMain WHERE DATE(dateTi

Re: COUNT returned rows of a SELECT

2008-07-31 Thread Rob Wultsch
On Wed, Jul 30, 2008 at 9:41 PM, Fish Kungfu <[EMAIL PROTECTED]> wrote: > Using MySQL commands only (not PHP's mysql_num_rows), is there a way to > COUNT the number of rows returned from a SELECT.GROUP BY? > > My primary SELECT query is this: > > SELECT aviName,MAX(dateTime) FROM aviTrackerMain

Re: COUNT returned rows of a SELECT

2008-07-30 Thread Ananda Kumar
SELECT aviName,MAX(dateTime) ,count(*) FROM aviTrackerMain WHERE DATE(dateTime) LIKE CONCAT(DATE(NOW()),'%') GROUP BY aviName; This will also give you count of rows On 7/31/08, Fish Kungfu <[EMAIL PROTECTED]> wrote: > > Using MySQL commands only (not PHP's mysql_num_rows), is there a way to >

Re: Count total number of records in db

2008-07-12 Thread Rob Wultsch
On Fri, Jul 11, 2008 at 4:24 AM, Warren Windvogel <[EMAIL PROTECTED]> wrote: > $tables = mysql_list_tables($DB_DBName); Not that it matters much, but mysql_list_tables() is deprecated. -- Rob Wultsch -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:

Re: Count total number of records in db

2008-07-11 Thread Warren Windvogel
Radoulov, Dimitre wrote: mysql -NBe'show databases' | while IFS= read -r db; do printf "show tables from %s;\n" "$db" | mysql -N | while IFS= read -r t; do printf "select count(1) from %s.%s;\n" "$db" "$t" done done | mysql -N | awk '{ s += $1 }END{ print s }' I quickly

Re: Count total number of records in db

2008-07-11 Thread Radoulov, Dimitre
Warren Windvogel wrote: Hi, Can anyone tell me how to check the total number of records in a database in MySQL version 4.0 Googling doesn't seem to help and all previous posts assume version 5.* [...] Something like this: mysql -NBe'show databases' | while IFS= read -r db; do printf

Re: Count total number of records in db

2008-07-11 Thread MarisRuskulis
Warren Windvogel wrote: > Hi, > > Can anyone tell me how to check the total number of records in a > database in MySQL version 4.0 > Googling doesn't seem to help and all previous posts assume version 5.* > > Regards > Warren > for table you can use: SELECT COUNT(*) from the_table_name; in whole da

RE: Count syntax

2007-09-28 Thread Beauford
Thanks to all. > -Original Message- > From: Michael Dykman [mailto:[EMAIL PROTECTED] > Sent: September 28, 2007 1:36 PM > To: Beauford > Cc: mysql@lists.mysql.com > Subject: Re: Count syntax > > 1 means that 1 will be added to the sum if the condition >

RE: Count syntax

2007-09-28 Thread Weston, Craig \(OFT\)
attachments. Please notify the sender immediately by reply e-mail and delete the e-mail from your system. -Original Message- From: Michael Dykman [mailto:[EMAIL PROTECTED] Sent: Friday, September 28, 2007 1:36 PM To: Beauford Cc: mysql@lists.mysql.com Subject: Re: Count syntax 1 means

Re: Count syntax

2007-09-28 Thread Michael Dykman
1 and 0 do in this - > SUM(IF(supportertype = 'L', 1, 0)) > > > -Original Message- > > From: Baron Schwartz [mailto:[EMAIL PROTECTED] > > Sent: September 28, 2007 1:00 PM > > To: Beauford > > Cc: mysql@lists.mysql.com > > Subject: Re

RE: Count syntax

2007-09-28 Thread Beauford
Thanks - it works, but what does the 1 and 0 do in this - SUM(IF(supportertype = 'L', 1, 0)) > -Original Message- > From: Baron Schwartz [mailto:[EMAIL PROTECTED] > Sent: September 28, 2007 1:00 PM > To: Beauford > Cc: mysql@lists.mysql.com > Subject: Re: Coun

Re: Count syntax

2007-09-28 Thread Baron Schwartz
Beauford wrote: Hi, I have the following line of code and I keep getting wrong results from it. Can someone let me know what I'm doing wrong here. I just can't quite figure out the syntax that I need. select count(*) as numrows, count(supportertype) as leadcar from registrar where supportertype

Re: Count the number of specific rows

2006-12-29 Thread Philip Mather
Servers24, Hi Philip, Thank you very much for your help. Can you please tell me the differemce between COUNT(*) and COUNT(id) ? Thanks again. Actually sorry I was a bit misleading there. MySQL is optimized to calculate... SELECT COUNT(*) FROM aTable; ...but given the fact you've got a whe

Re: Count the number of specific rows

2006-12-29 Thread Peter Brawley
>I can simply use this : >SELECT id FROM sent WHERE member_id= ... >and the use count($result) to count the number, but I want a faster way, if >possible. SELECT COUNT(id) FROM sent WHERE member_id= ... PB Servers24 Network wrote: Hi, Well this question may seem funny, but I really need to

Re: Count the number of specific rows

2006-12-29 Thread Philip Mather
Servers24, Well this question may seem funny... No, a funny question would start something like "Why did the nun cross the road?". ;^) The problem is with counting a user's contribution in my site. Suppose that each user that send an email will be stored in DB. Now I want to count number of

Re: Count the number of specific rows

2006-12-29 Thread Duncan Hill
On Friday 29 December 2006 14:02, Servers24 Network wrote: > Hi, > > Well this question may seem funny, but I really need to know! > The problem is with counting a user's contribution in my site. Suppose that > each user that send an email will be stored in DB. Now I want to count > number of times

Re: Count query?

2006-10-20 Thread Dwight Tovey
chris smith wrote: > On 10/21/06, Dwight Tovey <[EMAIL PROTECTED]> wrote: >> Hello all >> Maybe it's been a long week, but I'm trying to do something that should >> be >> simple and just not getting anywhere. >> >> I have two tables: >> accounts >> acctid: int unique >> acctowner: char >> ..

Re: Count query?

2006-10-20 Thread chris smith
On 10/21/06, Dwight Tovey <[EMAIL PROTECTED]> wrote: Hello all Maybe it's been a long week, but I'm trying to do something that should be simple and just not getting anywhere. I have two tables: accounts acctid: int unique acctowner: char ... docs docid: int unique acctid: int docti

Re: Count of children

2006-09-27 Thread Douglas Sims
ch, 27. September 2006 15:48 An: André Hänsel; mysql@lists.mysql.com Betreff: re: Count of children André, Your sentence 'I want the count of all sub-entries for a specific entry' converts straight into SQL: 'I want' SELECT the count of all entries COUNT(*) FROM myT

Re: Count of children

2006-09-27 Thread Peter Brawley
André, I want the count of all sub-entries for a specific entry. Depends on the model you are using--edge list or nested sets? PB - André Hänsel wrote: I have a table with id and parent_id. I want the count of all sub-entries for a specific entry. I found several documents about worki

Re: Count of children

2006-09-27 Thread Jo�o C�ndido de Souza Neto
-entries. Example: A / \ B C / \ D E \ F So I want to know that C has 3 sub-nodes. > -Ursprüngliche Nachricht- > Von: Rob Desbois [mailto:[EMAIL PROTECTED] > Gesendet: Mittwoch, 27. September 2006 15:48 > An: André Hänsel; mysql@lists.mysq

re: Count of children

2006-09-27 Thread Rob Desbois
André, Your sentence 'I want the count of all sub-entries for a specific entry' converts straight into SQL: 'I want' SELECT the count of all entries COUNT(*) FROM myTable with a specific parent WHERE parent_id = 5 You've missed one of the major benefits of SQL - it's designed to rea

Re: Count of children

2006-09-27 Thread Jo�o C�ndido de Souza Neto
You can use it: SELECT parent_id, count( * ) FROM table WHERE parent_id =1 GROUP BY parent_id It´ll works fine. ""André Hänsel"" <[EMAIL PROTECTED]> escreveu na mensagem news:[EMAIL PROTECTED] I have a table with id and parent_id. I want the count of all sub-entries for a specific entry. I

Re: Count Fields of a Table

2006-09-22 Thread Ivan Aleman
Hello, @Mr. Price and Mr. Sims Thank you for show me the way, your tips where very educational. Thanks again. -- Iván Alemán ~ [[ Debian (Sid) ]] ~ -BEGIN GEEK CODE BLOCK- Version: 3.12 G!>GCM d+ s: a? C+++ UL++ P L+>+++$ E--- W++>+ N* o--- K- w O- M+ V-- PS++ PE-- Y PGP+>++ t-- 5 X R+

Re: Count Fields of a Table

2006-09-22 Thread Ivan Aleman
[...] Is there any way to find out, using only plain SQL, the number of fields of a given table. describe gives me the number of fields as result, but I need to get only that. Is it possible? Is it also possible to get only the fields name? AFIK there's no easy way to accomplish this using j

RE: Count Fields of a Table

2006-09-22 Thread Price, Randall
David, For the count of columns in a table: SELECT count(information_schema.columns.column_name) FROM information_schema.columns WHERE information_schema.columns.table_schema = 'database_name' ANDinformation_schema.columns.table_name = 'table_name' For the names of the col

Re: Count Fields of a Table

2006-09-22 Thread Douglas Sims
Hi David If you are using mysql 5.0 and up, you can select from the "INFORMATION_SCHEMA" database to get this information and much more. Following is an example using a database called "test" and a table called "t" To get the column names, use SELECT column_name FROM information_schema.co

Re: COUNT question

2006-09-18 Thread Jørn Dahl-Stamnes
On Monday 18 September 2006 14:55, Brent Baisley wrote: > You might try changing it to distinct if you are looking for unique count > of ids from each. SELECT a.a,aa,COUNT(DISTINCT b.id),COUNT(DISTINCT c.id) > FROM... This return 0 or 1 for b.id (1 if there is 1 or more records) and the correct v

Re: COUNT question

2006-09-18 Thread Brent Baisley
You might try changing it to distinct if you are looking for unique count of ids from each. SELECT a.a,aa,COUNT(DISTINCT b.id),COUNT(DISTINCT c.id) FROM... Since you are doing a left join, there always going to be something for b.id and c.id, even if the "value" is NULL. Distinct may work to fi

Re: COUNT question

2006-09-18 Thread Johan Höök
Hi Jörn, I don't think you can do it in one SELECT as you'll get the same number (the max) as soon as the COUNT goes above zero. If you think about how your resultset looks if you remove your COUNTs it becomes clearer. Say that for one a.a you have 3 matches in b and 2 matches in c, this will resu

Re: COUNT() Efficiency

2006-04-08 Thread Rhino
- Original Message - From: "Martin Gallagher" <[EMAIL PROTECTED]> To: Sent: Saturday, April 08, 2006 6:34 PM Subject: COUNT() Efficiency Hi, If I did a query like: SELECT COUNT(id) AS count1, COUNT(id) AS count2 FROM table WHERE id<100 Would MySQL run the COUNT() calculation once

Re: count(*) send a wrong value

2006-01-24 Thread Fabien SK
Le mardi 24 janvier 2006 à 19:23 +0100, Fabien SK a écrit : > Le mardi 24 janvier 2006 à 19:08 +0100, fabsk a écrit : > > Thank you a lot for your answer. The bug is there: if I drop the index > > 'tp_idx_part_solution', the result of the count is OK. > > I recreated this index and the cound drop

Re: count(*) send a wrong value

2006-01-24 Thread Fabien SK
Le mardi 24 janvier 2006 à 19:08 +0100, fabsk a écrit : > Thank you a lot for your answer. The bug is there: if I drop the index > 'tp_idx_part_solution', the result of the count is OK. > I recreated this index and the cound drop to "2" again. It doesn't happen on version 4.1.12-Max on my machine

Re: count(*) send a wrong value

2006-01-24 Thread fabsk
Le mardi 24 janvier 2006 à 09:19 +0100, Martijn Tonies a écrit : >> CREATE TABLE `tp_participation` ( >> `uid` int(11) NOT NULL default '0', >> `challenge_id` int(11) NOT NULL default '0', >> `response` text collate latin1_general_ci NOT NULL, >> `points` int(11) default NULL, >> UNIQUE K

Re: count(*) send a wrong value

2006-01-24 Thread Martijn Tonies
> Thank you a lot for your answer. I checked very carefully. The structure > of the table is (exported by phpMyAdmin): > > CREATE TABLE `tp_participation` ( > `uid` int(11) NOT NULL default '0', > `challenge_id` int(11) NOT NULL default '0', > `response` text collate latin1_general_ci NOT NU

Re: count(*) send a wrong value

2006-01-24 Thread fabsk
that > you aren't inadvertently writing the query incorrectly and that you really > DO have 10 rows with cid = 123. If you still get 2 as the result of your > query, I would recommend sending a bug report to MySQL. > > Rhino > > - Original Message - > Fro

Re: count(*) send a wrong value

2006-01-23 Thread Hank
My guess would that your PHP code is not written correctly. For instance, if you have a query in PHP: $sql="select * from my_table where cid=123"; ...and are using the PHP function mysql_numrows() to count the results, and then for your next test... you're just changing the query to: $sql="sele

Re: count(*) send a wrong value

2006-01-23 Thread Michael Stassen
fabsk wrote: > Hi, > > I'm facing a strange problem. I am using a database at my Internet > provider (Free, France). The type of table is MyISAM (no choice), MySQL > 4.1.15. I can do my tests with my PHP code or phpMyAdmin. > > The definition of my table is: > - uid, int > - cid, int > - response,

Re: count(*) send a wrong value

2006-01-23 Thread Rhino
o - Original Message - From: "fabsk" <[EMAIL PROTECTED]> To: Sent: Monday, January 23, 2006 5:32 PM Subject: Re: count(*) send a wrong value Thank you for you answer, but I read many times and I did not found something to answer my question (well, I did not know about the NUL

Re: count(*) send a wrong value

2006-01-23 Thread fabsk
Thank you for you answer, but I read many times and I did not found something to answer my question (well, I did not know about the NULL). In my case: - there is one table - htere is no "distinct" - there is a WHERE clause, so there is no optimisation - there is no other field and no "group by" I

Re: count(*) send a wrong value

2006-01-23 Thread Fabien SK
Thank you for you answer, but I read many times and I did not found something to answer my question (well, I did not know about the NULL). In my case: - there is one table - htere is no "distinct" - there is a WHERE clause, so there is no optimisation - there is no other field and no "group by" I

Re: count(*) send a wrong value

2006-01-23 Thread mysql
>From the MySQL 4.1 manual 12.10.1. GROUP BY (Aggregate) Functions COUNT(expr) Returns a count of the number of non-NULL values in the rows retrieved by a SELECT statement. COUNT() returns 0 if there were no matching rows. mysql> SELECT student.student_name,COUNT(*) ->FROM st

Re: Count two kinds of related records?

2005-08-05 Thread Brian Dunning
That's exactly what I'm looking for, thanks Eugene. :) On Aug 5, 2005, at 12:46 AM, Eugene Kosov wrote: Brian Dunning wrote: I'm searching a table of people who own properties, and I want to also include the total count of related properties, and the count of related properties whose

Re: Count two kinds of related records?

2005-08-05 Thread Gleb Paharenko
Hello. What do you think about this: SELECT a.name, COUNT(p.property_id) AS totalcount, SUM( IF(p.status = 'Active' AND p.approval = 'Active', 1, 0)) AS CCOUNT FROM accounts a, properties p WHERE a.account_id =

Re: Count two kinds of related records?

2005-08-05 Thread Eugene Kosov
Brian Dunning wrote: I'm searching a table of people who own properties, and I want to also include the total count of related properties, and the count of related properties whose (status is 'Active' and approval is 'Active'). I've got: select accounts.name, count(properties.property_id) a

Re: count(*)? was: Re: Query Question...

2005-07-16 Thread Michael Stassen
stipe42 wrote: I believe the difference is that count(*) includes nulls (because it is counting the number of records), whereas count(column) only counts the records where the column being counted is not null, regardless of the total number of rows. Right. COUNT(*) counts rows, COUNT(col) coun

Re: count(*)? was: Re: Query Question...

2005-07-16 Thread stipe42
I believe the difference is that count(*) includes nulls (because it is counting the number of records), whereas count(column) only counts the records where the column being counted is not null, regardless of the total number of rows. Hmm, on a related question then if I am correct above, does cou

Re: COUNT (*): Fast if NO where clause. slow with WHERE clause (yes, slow even if index is used).

2005-07-12 Thread Jocelyn Fournier
Hi, What about SELECT count(*) FROM table1 - SELECT count(*) FROM table1 WHERE status = 1 ? (this query should be mush faster) Regards, Jocelyn jpow wrote: Hi everyone, I have this problem of slow "count *" when I use a where clause. 1. I have a table of ~1m rows. 2. There is a "status" c

RE: Count(*)

2005-07-07 Thread Gordon Bruce
select count(distinct ordr_ID) from store -Original Message- From: Gana [mailto:[EMAIL PROTECTED] Sent: Thursday, July 07, 2005 3:01 PM To: mysql@lists.mysql.com Subject: Count(*) select count(*) from store group by orederId. For the above sql, I am not getting the count of unique orde

RE: Count(*)

2005-07-07 Thread Jay Blanchard
[snip] select count(*) from store group by orederId. For the above sql, I am not getting the count of unique order ids.. [/snip] select orderID, count(*) from store group by orderID -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysq

Re: Count of multiple columns

2005-05-08 Thread Rhino
As you have already seen, it is pretty difficult trying to count things in multiple columns. Although it is probably possible to do the counting, it might require programming logic in order to count for specific values in the various columns and then store the subtotals for each column so that they

Re: Count of multiple columns

2005-05-08 Thread mfatene
Selon Micha Berdichevsky <[EMAIL PROTECTED]>: > Hi. > I have a table that store different items. For each items, I can attach > up to 5 different textual categories. > Those categories are free-text, and different columns can have the same > values (example below). > I am trying to select the coun

Re: COUNT Problem

2004-10-18 Thread Frederic Wenzel
> >A subselect may help: > >[...] > >Don't know ATM if it can be done more easily, but a query like this > >should probably work. > > > It can be done without a sub-query: > [...] > > That *should* work, barring any typos or ommisions I may have made. I > used LEFT JOIN because of personal prefere

RE: COUNT Problem

2004-10-17 Thread Jose Miguel Pérez
Hi Shaun! I beg you pardon, my last message was incomplete! I will quote the last lines from my previous post: ---8<- Cut here ---8<--- > > - Thanks to the LIMIT clause, we get only the first result, which by > the way is one of the projects with the most assigned tasks.

Re: COUNT Problem

2004-10-17 Thread Chris
Frederic Wenzel wrote: On Sun, 17 Oct 2004 19:36:34 +, shaun thornburgh <[EMAIL PROTECTED]> wrote: A Project will have 1 or more tasks assigned to it. Using the following query, how can I modify it so that I can find out the largest number of tasks assigned to a group of projects. SELECT P.*

RE: COUNT Problem

2004-10-17 Thread Jose Miguel Pérez
Hi Shaun! > A Project will have 1 or more tasks assigned to it. Using the > following > query, how can I modify it so that I can find out the largest > number of > tasks assigned to a group of projects. > > SELECT P.*, T.* > FROM Projects P, Tasks T > WHERE P.Project_ID = T.Project_ID > AND P

Re: COUNT Problem

2004-10-17 Thread Frederic Wenzel
On Sun, 17 Oct 2004 19:36:34 +, shaun thornburgh <[EMAIL PROTECTED]> wrote: > A Project will have 1 or more tasks assigned to it. Using the following > query, how can I modify it so that I can find out the largest number of > tasks assigned to a group of projects. > > SELECT P.*, T.* > FROM Pr

Re: COUNT Problem

2004-10-17 Thread Merlin, the Mage
Hi, Tihs looks to me as too few information. What is in your tables (the information)? What does the query return (a empty set)? Maybe 'cause in your where clause where you have Project_ID >2 you should have Project_ID=2? Or you have several projects with ID>2 and you want tasks for all of

Re: Count() within Join

2004-08-06 Thread SGreen
I think what you need is a pivot table (aka: cross tab report): SELECT c.id , c.campaign_name , count(1) as total , SUM(if(a.status='optin',1,0)) as optin , SUM(if(a.status='optout',1,0)) as optout FROM addresses as a INNER JOIN addresses_incampaign as i o

Re: COUNT

2004-05-17 Thread Dan Nelson
In the last episode (May 17), Gustavo Andrade said: > select count(distinct membros.ID) as total_membros, count(distinct > replays.ID) as total_replays, count(distinct downloads.ID) as > total_downloads from membros,replays,downloads; > > if one of the tables have 0 records all the counts will tu

Re: COUNT

2004-05-16 Thread John Fawcett
From: "Gustavo Andrade" > select count(distinct membros.ID) as total_membros, count(distinct > replays.ID) as total_replays, count(distinct downloads.ID) as > total_downloads from membros,replays,downloads; Why join three tables to count the records in each one? I'm sure the performance will be po

Re: count() on multiple similar tables?

2004-05-04 Thread Ken Gieselman
Great! Thanks for the quick pointer! ken Quoting Diana Soares <[EMAIL PROTECTED]>: > You may use MERGE TABLES: > > http://dev.mysql.com/doc/mysql/en/MERGE.html > > -- > Diana Soares > > On Tue, 2004-05-04 at 10:08, Ken Gieselman wrote: > > Heya folks -- > > > > Trying to come up with a way

Re: count() on multiple similar tables?

2004-05-04 Thread Diana Soares
You may use MERGE TABLES: http://dev.mysql.com/doc/mysql/en/MERGE.html -- Diana Soares On Tue, 2004-05-04 at 10:08, Ken Gieselman wrote: > Heya folks -- > > Trying to come up with a way to count across multiple tables, and failing > miserably. I need a simple way, preferably better than loope

Re: Count all rows if limit by?

2004-03-22 Thread Victor Spång Arthursson
Thanks a lot, Jigal and Egor - just what i searched for! Sincerely Victor -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

Re: Count all rows if limit by?

2004-03-19 Thread Egor Egorov
Victor Sp?ng Arthursson <[EMAIL PROTECTED]> wrote: > Hi all! > > Is there a simple way to get the total number of rows a result _should_ > have had if no where-clause where present? Without doing a second > query? > If you want to get total number of rows in the table (without WHERE and withou

Re: Count all rows if limit by?

2004-03-19 Thread Jigal van Hemert
From: "Victor Spång Arthursson" <[EMAIL PROTECTED]> > Is there a simple way to get the total number of rows a result _should_ > have had if no where-clause where present? Without doing a second > query? Example from http://www.mysql.com/doc/en/Information_functions.html : mysql> SELECT SQL_CALC_F

Re: Count()

2004-02-25 Thread Jacque Scott
That works. I knew I was missing something simple. It was the GROUP BY and the HAVING together. Thank you very much. >>> Michael Stassen <[EMAIL PROTECTED]> 2/25/2004 9:05:34 AM >>> Jacque Scott wrote: > My program, NCR (Non-Conformity Report), keeps track of problems with > items that are r

Re: Count()

2004-02-25 Thread Michael Stassen
Jacque Scott wrote: My program, NCR (Non-Conformity Report), keeps track of problems with items that are received from vendors. I am creating a report where the user can retrieve a list of vendors that have had a NCR written against them a certain number of times. For example, if the user wants

Re: count max days

2003-10-20 Thread Colin Kettenacker
Whenever you use the Max() function on a column while accessing other columns at the same time you need a GROUP BY statement so that the MAX() function knows how to "group" it's results. I suggest you look into the manual for this. In fact it has a tutorial showing you options on how to do exactly

Re: COUNT(*) faster?

2003-10-06 Thread Paul DuBois
At 11:40 -0500 10/6/03, Steve Buehler wrote: I am using PHP & MySQL for a program that I am writing. I have a table in my database that has a column with dates in it in the form -mm-dd. Sometimes there is nothing in the table with the search date that I am using. Other times there might b

Re: COUNT(*) faster?

2003-10-06 Thread Director General: NEFACOMP
I think this is OK. But if you want to get a recordset with data and know how much records you have with only ONE query, you may use: $date=2003-02-16; SELECT col1, col2, coln FROM `games` WHERE `date`='$date' $num_rows=0; $num_rows=mysql_num_rows($rs_resource_identifier); I don't remember exact

Re: Count Rows?

2003-07-04 Thread Jeremy Zawodny
On Wed, Jul 02, 2003 at 10:57:18AM -0500, Roy W wrote: > Is there a simple MySQL command that will give a Row Count (# of records) > WITHOUT running a select (huge database) If it's a MyISAM table, just run a SELECT COUNT(*) FROM table_name. It's really efficient. Try it. :-) -- Jeremy D. Zawodn

RE: Count Rows?

2003-07-02 Thread Mike Hillyer
If your table is MyISAM, then SELECT COUNT(*) FROM tablename Will return a rowcount without a major performance hit as the rowcount is stored and a table scan is not needed. Regards, Mike Hillyer www.vbmysql.com > -Original Message- > From: Roy W [mailto:[EMAIL PROTECTED] > Sent: Wed

RE: Count on Multiple Tables

2003-06-06 Thread Mike Hillyer
ph [mailto:[EMAIL PROTECTED] Sent: Thursday, June 05, 2003 10:33 AM To: Mike Hillyer; [EMAIL PROTECTED] Subject: RE: Count on Multiple Tables CREATE TABLE `affiliate_clickthroughs` ( `affiliate_clickthrough_id` int(11) NOT NULL auto_increment, `affiliate_id` int(11) NOT NULL default '0&#

RE: Count on Multiple Tables

2003-06-06 Thread Ralph
ng_status` int(5) NOT NULL default '0', `payment_date` datetime NOT NULL default '-00-00 00:00:00', `commission_percent` decimal(4,2) NOT NULL default '0.00', PRIMARY KEY (`affiliate_orders_id`) ) TYPE=MyISAM; -Original Message- From: Mike Hillyer [mailto:[EMAI

RE: Count on Multiple Tables

2003-06-06 Thread Mike Hillyer
Can you show some table structure so we have something work with? It's hard to recommend a query when we do not know what your sales table structure is. Regards, Mike Hillyer www.vbmysql.com -Original Message- From: Ralph [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 04, 2003 4:00 PM

Re: COUNT(DISTINCT ...)

2003-03-12 Thread Paul DuBois
At 16:42 -0500 3/12/03, Bob Sawyer wrote: HELP! I'm getting the following error: -- Error (SQL): SELECT date, subject, location, private, id, duration, dategroup_id, COUNT(DISTINCT subject) AS appointment_count, inituserid FROM mgw_calendar WHERE userid=1 AND SUBSTRING(date,1,8) = '200

  1   2   >