Fw: Weird problem with mysql_query

2008-09-10 Thread DaWiz





- Original Message - 
From: Darryle Steplight [EMAIL PROTECTED]

To: MySql [EMAIL PROTECTED]
Cc: mysql@lists.mysql.com
Sent: Tuesday, September 09, 2008 6:59 PM
Subject: Re: Weird problem with mysql_query



Hi G,
  There is nothing weird about your results. When you do a Count(*)
without a GROUP BY(someColumn) you are essentially asking MySQL how
many rows are present in the table. But when you do use Group By
someColum , you are asking MySql how many  rows do I have of
someColumn .  It's just a good practice to use GROUP BY when you
want to a count of a specific column .

mysql select count(*) as 'Count' from logins GROUP BY dawiz


I found my problem - it turned out to be a misconception on my part; I was
using sprintf(buf,%d, row[i]) if it was a numeric field - this was
printing the address rather than the value.  Apparently even though the 
data

is type MYSQL_TYPE_LONGLONG it should be treated as char.

G Vaughn


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



MySQL University session on September 11: openSolaris Web Stack

2008-09-10 Thread Stefan Hinz

Hi,

Sorry for the extra mail, but our presenters have just told me that they 
can't do the regular time for this session, so I've moved it to be 3 
hours later (9:00 PST / 16:00 UTC / 17:00 GMT / 18:00 CET).


The rest of the announcement remains valid:

This Thursday,  Jyri Virkki  Murthy Chintalapati will give a MySQL
University session:

http://forge.mysql.com/wiki/OpenSolaris_Web_Stack
(topic: openSolaris Web Stack)

Please register for this session by filling in your name on the session
Wiki page. Registering is not required but appreciated. That Wiki page
also contains a section to post questions. Please use it!

MySQL University sessions normally start at 13:00 UTC (summer) or 14:00
UTC (winter); see: http://forge.mysql.com/wiki/MySQL_University for more
time zone information.

Those planning to attend a MySQL University session for the very first
time should probably read the instructions for attendees,
http://forge.mysql.com/wiki/Instructions_for_Attendees.

See http://forge.mysql.com/wiki/MySQL_University#Upcoming_Sessions for
the complete list of upcoming University sessions.

-Stefan
--
***
Sun Microsystems GmbHStefan Hinz
Sonnenallee 1Manager Documentation, Database Group
85551 Kirchheim-Heimstetten  Phone: +49-30-82702940
Germany  Fax:   +49-30-82702941
http://www.sun.de/mysql  mailto: [EMAIL PROTECTED]

Amtsgericht Muenchen: HRB161028
Geschaeftsfuehrer: Thomas Schroeder, Wolfgang Engels, Dr. Roland Boemer
Vorsitzender des Aufsichtsrates: Martin Haering
***



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Weird problem with mysql_query

2008-09-10 Thread Andy Shellam
I don't have that much experience with MySQL having mostly worked with 
MSSQL, but I'm sure the logic is still the same.  I believe the query 
select count(*) as 'count' from logins GROUP BY dawiz will fail 
because dawiz is not a column, it's a value within the table.


If I'm not mistaken, a GROUP BY is only required when the COUNT needs to 
be split into groups:


e.g.

select player, count(*) as 'Count' from logins GROUP BY player;

player   | Count
---
player1 |  12
player2 |  7
player3 | 35

or:
select count(*) as 'Count' from logins WHERE player = 'player1';

Count
-
12

or:
select count(*) as 'Count' from logins;

Count
-
54

Regards,

Andy

Darryle Steplight wrote:

Hi G,
   There is nothing weird about your results. When you do a Count(*)
without a GROUP BY(someColumn) you are essentially asking MySQL how
many rows are present in the table. But when you do use Group By
someColum , you are asking MySql how many  rows do I have of
someColumn .  It's just a good practice to use GROUP BY when you
want to a count of a specific column .

mysql select count(*) as 'Count' from logins GROUP BY dawiz

The above query should return the results you are looking for.



On Tue, Sep 9, 2008 at 6:06 PM, MySql [EMAIL PROTECTED] wrote:
  

We are running MySql version 5.0.45-Debian_1ubuntu3.1-log Debian etch 
distribution under Ubuntu.
If I submit the following query via mysql_query it acts as if the where is not 
there:

select count(*) as 'Count' from logins where player = 'aqwert';

this returns:
Count
143578160


Submitting the same query at a MySql prompt works correcty:

mysql select count(*) as 'Count' from logins where player = 'dawiz';
+---+
| Count |
+---+
|  6026 |
+---+
1 row in set (0.00 sec)

Modifying the query to use a group by returns the correct count:

   TotalCount
   Total 6026

Is there something I should know about mysql_query and a simple count(*)?

G Vaughn




  


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



REGEXP case insensitive SQL QUERY

2008-09-10 Thread Bala Balaravi
How can I use REGEXP case insensitive SQL QUERY

Ex: select * from table where a REGEXP 'abc' will match both 'abc' and 'ABC'