Group by with an IF

2006-08-13 Thread Steffan A. Cline
I have the following query: select *, if( season_week_date = 2006-08-16, on, off ) as stat, sum(overall_points) as total_points from rosters r left join celebs c on c.celeb_id = r.celeb_id where season_id=5062 and user_id=1 group by r.celeb_id order by overall_rank, ln, fn; It almost works

logging

2006-08-13 Thread Josh Milane
Hello, I realize that this is a silly question, but I cannot figure it out. I don't know why. Id really appreciate your help. I cannot get mysql to do general logging. My my.ini reads like this: -- #This File was made using the WinMySQLAdmin 1.4 Tool

Re: Do I really need a subquery?

2006-08-13 Thread Peter Brawley
Geoffrey, Do I really need that subquery? You need its scalar result just once, so why not ... SELECT url, @maxcount:=COUNT(1) FROM bi_bookmarks WHERE date NOW() - INTERVAL 86400 SECOND GROUP BY url ORDER BY count DESC LIMIT 0, 1; SELECT title, url, COUNT(1) AS count, CEIL(COUNT(1) /

mysql++ problem(undefined symbol to)

2006-08-13 Thread ali asghar torabi parizy
hello. i want to connect to mysql from c++ . i examine any version or platform. i use mysql5 and 4 in suse10 with gcc.then examine mingw and mysql5 and 4 and 3 for severeal times but i can't solve this problem.when i want to compile examples of mysql++ following error appeared:

Finding the last row that has

2006-08-13 Thread André Hänsel
Hi, I have one table with images (image_id, name, filename, vote_count) and one table with votes (vote_id, image_id, vote_value, user_id). I want to find the image with the lowest vote_count that a known user has not yet voted. For MySQL 4.0 I have the following: SELECT i.* FROM images i LEFT

Joining result sets into 1 row

2006-08-13 Thread Steffan A. Cline
I am in a situation where I have say 1 column called attribute I need and the result set is 3 rows. i.e. ROW 1 - Mechanic ROW 2 - Carpenter ROW 3 - Plumber I want to have the rows returned as one row Such as ROW 1 Mechanic, Carpenter, Plumber Something like a literal join would be beautiful such

Re: Joining result sets into 1 row

2006-08-13 Thread Ow Mun Heng
On Sun, 2006-08-13 at 15:53 -0700, Steffan A. Cline wrote: I am in a situation where I have say 1 column called attribute I need and the result set is 3 rows. i.e. ROW 1 - Mechanic ROW 2 - Carpenter ROW 3 - Plumber I want to have the rows returned as one row Such as ROW 1 Mechanic,

random sort?

2006-08-13 Thread Tanner Postert
so if i have a list of records... id name other 1 water H2O 2 water aqua 3 water liquid so i want to select other where name = 'water' but i want to only return 1 result, and for that result to be a random value. is there a way to sort by rand() ? or something similar? or am i better of

Re: random sort?

2006-08-13 Thread Chris
Tanner Postert wrote: so if i have a list of records... id name other 1 water H2O 2 water aqua 3 water liquid so i want to select other where name = 'water' but i want to only return 1 result, and for that result to be a random value. is there a way to sort by rand() ? Yes. Funnily

Re: non-text data

2006-08-13 Thread Chris
Dave Shariff Yadallee - System Administrator a.k.a. The Root of the Problem wrote: I use SELECT all from * ... and one row is a gif. How do I get that gif to appear as a gif and not text? In your connecting programming language. Mysql doesn't know or care whether it's a gif, pdf, word doc or

Re: problems with sql-mysql mode of emacs on Windows

2006-08-13 Thread Chris
Jieqi Wang wrote: I am using WinXP, GNU Emacs 23, MySQL 5. When I start a mysql process with `sql-mysql' in emacs, no output is displayed in the buffer until I quit or kill the process. After I add the following line into the initialization file of emacs, (setq sql-mysql-options '(-C -t

Re: Changed?

2006-08-13 Thread Chris
MYSQL wrote: Hi, I recently updated to version 4.1.2 from a slightly older one like 4.1.11 or something. But I am now having a problem. Before,this query would work fine: Select distinctrow * from mytable order by mydatecolumn. mydatecolumn is a column of type date. This used to return

silly trigger question

2006-08-13 Thread Josh Milane
Hi, Would something like this make it so that every time there was a new row inserted on TEST, a row with the new values was inserted on LOG_TABLE? I am not sure if you can reference NEW.id and all the NEW values directly and send them in a trigger... Thanks... CREATE TRIGGER test.data_table_au

Random SELECT on subset

2006-08-13 Thread Mark
Dear MySQL-ers, Using MySQL 4.1.20, I'm trying to do a complex query on a subset; well, complex to me, that is. :) In Perl, I'm trying to get 4 random entries from a subset WHERE processed = '1' and columnId is unique. Like so: $sth = $dbh-prepare (SELECT columnId FROM queue WHERE columnId =

Re: Random SELECT on subset

2006-08-13 Thread Chris
Mark wrote: Dear MySQL-ers, Using MySQL 4.1.20, I'm trying to do a complex query on a subset; well, complex to me, that is. :) In Perl, I'm trying to get 4 random entries from a subset WHERE processed = '1' and columnId is unique. Like so: $sth = $dbh-prepare (SELECT columnId FROM queue WHERE

RE: Random SELECT on subset

2006-08-13 Thread Mark
-Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: maandag 14 augustus 2006 3:55 To: Mark Cc: mysql@lists.mysql.com Subject: Re: Random SELECT on subset In Perl, I'm trying to get 4 random entries from a subset WHERE processed = '1' and columnId is unique.

Re: Random SELECT on subset

2006-08-13 Thread Chris
Mark wrote: -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: maandag 14 augustus 2006 3:55 To: Mark Cc: mysql@lists.mysql.com Subject: Re: Random SELECT on subset In Perl, I'm trying to get 4 random entries from a subset WHERE processed = '1' and columnId is unique.

RE: Random SELECT on subset

2006-08-13 Thread Mark
-Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: maandag 14 augustus 2006 4:18 To: Mark Cc: mysql@lists.mysql.com Subject: Re: Random SELECT on subset Then I want to select 4 random columnIDs, but only from the subset WHERE processed = '1' (so, from the group

Re: Connection Help - Stupid Question, sorry to bother.

2006-08-13 Thread Chris
Chris W wrote: By default MySQL uses port 3306 so you need to be sure that port is open on the server, and not blocked by a firewall. You also need to be sure the user you are trying to login as can login remotely. In the MySQL user data base, there is a column for host which is the host

Re: Group by with an IF

2006-08-13 Thread Chris
Steffan A. Cline wrote: I have the following query: select *, if( season_week_date = 2006-08-16, on, off ) as stat, sum(overall_points) as total_points from rosters r left join celebs c on c.celeb_id = r.celeb_id where season_id=5062 and user_id=1 group by r.celeb_id order by

Re: mysql++ problem(undefined symbol to)

2006-08-13 Thread Chris
ali asghar torabi parizy wrote: hello. i want to connect to mysql from c++ . i examine any version or platform. i use mysql5 and 4 in suse10 with gcc.then examine mingw and mysql5 and 4 and 3 for severeal times but i can't solve this problem.when i want to compile examples of mysql++

Re: Finding the last row that has

2006-08-13 Thread Chris
André Hänsel wrote: Hi, I have one table with images (image_id, name, filename, vote_count) and one table with votes (vote_id, image_id, vote_value, user_id). I want to find the image with the lowest vote_count that a known user has not yet voted. For MySQL 4.0 I have the following: SELECT

Re: Random SELECT on subset

2006-08-13 Thread Chris
Mark wrote: -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: maandag 14 augustus 2006 4:18 To: Mark Cc: mysql@lists.mysql.com Subject: Re: Random SELECT on subset Then I want to select 4 random columnIDs, but only from the subset WHERE processed = '1' (so, from the

Re: non-text data

2006-08-13 Thread Dave Shariff Yadallee - System Administrator a.k.a. The Root of the Problem
On Mon, Aug 14, 2006 at 10:42:50AM +1000, Chris wrote: Dave Shariff Yadallee - System Administrator a.k.a. The Root of the Problem wrote: I use SELECT all from * ... and one row is a gif. How do I get that gif to appear as a gif and not text? In your connecting programming language.

query needed

2006-08-13 Thread VenuGopal Papasani
Hi, i got a table datavalue as follows code period value c1 20051 c2 20052 c32006 3 c4

RE: Random SELECT on subset

2006-08-13 Thread Mark
-Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: maandag 14 augustus 2006 4:54 To: Mark Cc: mysql@lists.mysql.com Subject: Re: Random SELECT on subset Hmm, this still does not do what I want: SELECT columnId FROM queue WHERE processed = '1' ORDER BY RAND() LIMIT 4

Re: query needed

2006-08-13 Thread Chris
VenuGopal Papasani wrote: Hi, i got a table datavalue as follows code period value c1 20051 c2 20052 c32006 3

Re: non-text data

2006-08-13 Thread Chris
Dave Shariff Yadallee - System Administrator a.k.a. The Root of the Problem wrote: On Mon, Aug 14, 2006 at 10:42:50AM +1000, Chris wrote: Dave Shariff Yadallee - System Administrator a.k.a. The Root of the Problem wrote: I use SELECT all from * ... and one row is a gif. How do I get that gif

Re: Random SELECT on subset

2006-08-13 Thread Chris
Mark wrote: -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: maandag 14 augustus 2006 4:54 To: Mark Cc: mysql@lists.mysql.com Subject: Re: Random SELECT on subset Hmm, this still does not do what I want: SELECT columnId FROM queue WHERE processed = '1' ORDER BY RAND()

RE: Random SELECT on subset

2006-08-13 Thread Mark
-Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: maandag 14 augustus 2006 6:32 To: Mark Cc: mysql@lists.mysql.com Subject: Re: Random SELECT on subset Thanks to you, the query has been greatly simplified, but the result is still the same: every once in a while

Re: Random SELECT on subset

2006-08-13 Thread Chris
Mark wrote: -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: maandag 14 augustus 2006 6:32 To: Mark Cc: mysql@lists.mysql.com Subject: Re: Random SELECT on subset Thanks to you, the query has been greatly simplified, but the result is still the same: every once in a

Re: query needed

2006-08-13 Thread VenuGopal Papasani
Once again i send the table data: Code Period Value c1 2004 22 c1 2005 10 c2 2005 15 c3 2005 20 c4 2005 15 c5 2005 5 c6 2005 30 c7 2005

RE: query needed

2006-08-13 Thread Peter Lauri
SELECT SUM(IF(code='c1', code, IF(code='c2', code, 0))) - SUM(IF(code='c4', code, IF(code='c5', code, 0))) FROM datavalue; -Original Message- From: VenuGopal Papasani [mailto:[EMAIL PROTECTED] Sent: Monday, August 14, 2006 11:26 AM To: mysql@lists.mysql.com Subject: query needed Hi, i