Re: conditional sum

2008-09-05 Thread kalin m
i got closer but i can't figure out this: individually: A) select a.job, sum(b.money) from t1 as a left join t2 as b on a.account = b.account where a.job = "ca1" and b.money > 0; +--+---+ | job | sum(b.money) | +--+-

Selecting around a circular reference?

2008-09-05 Thread Brian Dunning
I'm trying to calculate glycemic index of all food items eaten in a day with a single SELECT. The problem is the calculation for glycemic index of each item requires a total of all items' carbs. It's like a circular reference. Here's what I'm trying: SELECT sum(foodi

Re: Totaling from several tables away

2008-09-05 Thread Brian Dunning
Thanks, that was exactly what I needed. :-) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

Re: INDEXING ALL COLUMNS

2008-09-05 Thread Krishna Chandra Prajapati
More details. CREATE TABLE mailer_student_status ( student_id decimal(22,0) NOT NULL default '0', param varchar(128) NOT NULL default '', value varchar(128) default NULL, PRIMARY KEY (student_id,param). KEY idx_value (value) ) SELECT VALUE FROM mailer_student_status WHERE student_id

conditional sum

2008-09-05 Thread kalin m
hi... how do i do conditional sums? like: select a.job, sum(if b.amount > 0 then amount end if ) from t1 as a left join t2 as b on a.account=b.accoun where a.account = b.account group by a.job; or select a.job, if b.amount > 0 then sum(b.amount) end if from t1 as a left join t2 as b o

Wierd INSERT ... SELECT syntax problem

2008-09-05 Thread Dan Tappin
I have an existing data set - here is an example (the real one is more complex than this) LOC DATA - A 1 B 2 C 3 D 4 E 5 F 6 ... and I am looking to run some sort of INSERT ... SELECT on this to make a new table like this: LOC DATA

Re: INDEXING ALL COLUMNS

2008-09-05 Thread ewen fortune
Hi, Well at first glance its hard to tell since "param" and "value" don't say a lot about the nature of the data. If this is innodb, you can have a PRIMARY KEY of student_id (assuming its unique) and a separate index on param, this is because of the way innodb is structure, the primary key is alwa

Re: INDEXING ALL COLUMNS

2008-09-05 Thread Aaron Blew
We'd need more information on what the where clauses of the queries look like to assist with this. -Aaron On 9/5/08, Krishna Chandra Prajapati <[EMAIL PROTECTED]> wrote: > Hi, > > What would you say about the below table . What can i do to make it more > efficient. > > CREATE TABLE mailer_student

Re: Totaling from several tables away

2008-09-05 Thread Darryle Steplight
Hi Brian, Try this. SELECT SUM(mi.calories) FROM Meal_Items as mi, People as P, Meals as m WHERE p.Person_ID = '5' AND p.Person_ID=m.Person_ID AND m.Date = '2009-09-04' AND m.Meal_ID = mi.Meal_id GROUP BY p.Person_ID Hi Gerald: This part is throwing me off " ON People.Name=Meals.Name" . But I

Re: INDEXING ALL COLUMNS

2008-09-05 Thread Krishna Chandra Prajapati
Hi, What would you say about the below table . What can i do to make it more efficient. CREATE TABLE mailer_student_status ( student_id decimal(22,0) NOT NULL default '0', param varchar(128) NOT NULL default '', value varchar(128) default NULL, PRIMARY KEY (student_id,param). KEY idx_va

Re: Totaling from several tables away

2008-09-05 Thread Gerald L. Clark
Brian Dunning wrote: How do I query "How many calories did Brian eat on 2009-09-04"? Table:People +---+---+ + Person_ID + Name | +---+---+ | 5 | Brian | +---+---+ Table:Meals +-+---+---++ | Meal_ID | Person_ID | Me

Totaling from several tables away

2008-09-05 Thread Brian Dunning
How do I query "How many calories did Brian eat on 2009-09-04"? Table:People +---+---+ + Person_ID + Name | +---+---+ | 5 | Brian | +---+---+ Table:Meals +-+---+---++ | Meal_ID | Person_ID | Meal_Name | Date |

Re: INDEXING ALL COLUMNS

2008-09-05 Thread ewen fortune
Hi, Following on from what Mike mentioned, indexing all columns does not really help as MySQL will at most use one index for a query, so its important to pick your indexes carefully and consider constructing composite indexes. An index on a single column may not even be used due to poor cardinalit

Re: INDEXING ALL COLUMNS

2008-09-05 Thread Mike Zupan
As your table grows your inserts will start to get slower and slower. You run into the issue of locking a table due to re-creating the indexes. Also wasted space for indexes On 9/5/08, Krishna Chandra Prajapati <[EMAIL PROTECTED]> wrote: > > Hi all, > > I am looking for, is there any specific re

INDEXING ALL COLUMNS

2008-09-05 Thread Krishna Chandra Prajapati
Hi all, I am looking for, is there any specific reason for not indexing all columns of a table. whats the impact on the performance. Although indexing is meant for getting great performance. So, why indexing all columns is not feasible. (Read in docs that all columns should not be indexed) --

Re: Need Help Migrating DB from MySQL 5.0.x to MySQL 4.0.x

2008-09-05 Thread Werner D.
Shaun Adams schrieb: > When I perform a dump in mysql5 to mysql 4 DB, I get the error (below). > Does anyone know how I can resolve this? > > > > QUERY (windows server from the cmd prompt) > > mysqldump --lock-tables --user=root [SOURCE DB] | mysql --user=[USERNAME] > --password=[PASSWORD] --

Re: innodb/myisam performance issues

2008-09-05 Thread Michael Dykman
On Fri, Sep 5, 2008 at 12:55 PM, Josh Miller <[EMAIL PROTECTED]> wrote: > Aaron Blew wrote: >> >> Here are a couple ideas: >> * Decrease innodb_autoextend_increment to 8 or even 4. You may see >> additional IO wait because you're pre-allocating space in chunks >> disproportinate to what you immedi

Re: innodb/myisam performance issues

2008-09-05 Thread Josh Miller
Aaron Blew wrote: Here are a couple ideas: * Decrease innodb_autoextend_increment to 8 or even 4. You may see additional IO wait because you're pre-allocating space in chunks disproportinate to what you immediately need, causing bursty performance. * If your remaining MyISAM tables don't need it

Need Help Migrating DB from MySQL 5.0.x to MySQL 4.0.x

2008-09-05 Thread Shaun Adams
When I perform a dump in mysql5 to mysql 4 DB, I get the error (below). Does anyone know how I can resolve this? QUERY (windows server from the cmd prompt) mysqldump --lock-tables --user=root [SOURCE DB] | mysql --user=[USERNAME] --password=[PASSWORD] --host=[HOST] [TARGET DB] ERROR MESS

RE: Erro 1406 Data too long

2008-09-05 Thread Jerry Schwartz
From: Roland Kaber [mailto:[EMAIL PROTECTED] Sent: Thursday, September 04, 2008 11:24 PM To: Jerry Schwartz Cc: mysql@lists.mysql.com Subject: Re: Erro 1406 Data too long It looks like it is really a character set conflict. The copyright character © is ascii 169 and is part of latin-1. Howeve

DRBD Setup & Replication

2008-09-05 Thread Benjamin Wiechman
I currently have a MySQL server in production and am considering protecting it with DRBD. The kicker is that it is a production database and so I can't take it offline, or can take it offline for only a very (several minutes max) short period of time. Is it feasible to get this working without much