Re: sub query to daily usage subtraction

2010-12-23 Thread 杨涛涛
bases on date .Here id is same. I am new to witting mysql query (learning). I think this can be done using sub query. any help will be really appreciated . Thanks Rg Mohan L

sub query to daily usage subtraction

2010-11-30 Thread Mohan L
storage bases on date .Here id is same. I am new to witting mysql query (learning). I think this can be done using sub query. any help will be really appreciated . Thanks Rg Mohan L

Retrieve three columns in sub query

2010-08-25 Thread Tompkins Neil
Hi Is it possible in MySQL 5.1 to retrieve three columns in a select sub-query like below : SELECT student_age, SELECT (student_subjects_id, random_mark, subject FROM student_subjects ORDER BY RAND(), LIMIT 1) FROM students WHERE student_age 10 ORDER BY RAND() LIMIT 1 I've looked and tried

Re: Retrieve three columns in sub query

2010-08-25 Thread Jo�o C�ndido de Souza Neto
columns in a select sub-query like below : SELECT student_age, SELECT (student_subjects_id, random_mark, subject FROM student_subjects ORDER BY RAND(), LIMIT 1) FROM students WHERE student_age 10 ORDER BY RAND() LIMIT 1 I've looked and tried everything, but nothing seems to work

Re: Retrieve three columns in sub query

2010-08-25 Thread Tompkins Neil
Souza Neto Tompkins Neil neil.tompk...@googlemail.com escreveu na mensagem news:aanlkti=djkujcsg=kf29sjsp0yllhmhb02mqzdvzd...@mail.gmail.com... Hi Is it possible in MySQL 5.1 to retrieve three columns in a select sub-query like below : SELECT student_age, SELECT (student_subjects_id

RE: Retrieve three columns in sub query

2010-08-25 Thread misiaQ
query Hi Is it possible in MySQL 5.1 to retrieve three columns in a select sub-query like below : SELECT student_age, SELECT (student_subjects_id, random_mark, subject FROM student_subjects ORDER BY RAND(), LIMIT 1) FROM students WHERE student_age 10 ORDER BY RAND() LIMIT 1 I've looked and tried

Re: Retrieve three columns in sub query

2010-08-25 Thread Jo�o C�ndido de Souza Neto
three columns in a select sub-query like below : SELECT student_age, SELECT (student_subjects_id, random_mark, subject FROM student_subjects ORDER BY RAND(), LIMIT 1) FROM students WHERE student_age 10 ORDER BY RAND() LIMIT 1 I've looked and tried everything, but nothing seems

Re: Retrieve three columns in sub query

2010-08-25 Thread Tompkins Neil
: Tompkins Neil [mailto:neil.tompk...@googlemail.com] Sent: Wednesday, August 25, 2010 1:23 PM To: [MySQL] Subject: Retrieve three columns in sub query Hi Is it possible in MySQL 5.1 to retrieve three columns in a select sub-query like below : SELECT student_age, SELECT

Re: Slow when using sub-query

2010-06-03 Thread Johan De Meersman
select_type: SIMPLE table: prod type: ref possible_keys: prod_pub_prod_id,pub_id,pub_id_2 key: pub_id key_len: 48 ref: const rows: 1543 Extra: Using where === Outer Query with Sub-query === us-gii EXPLAIN - SELECT prod_num FROM

RE: Slow when using sub-query

2010-06-03 Thread Jerry Schwartz
-Original Message- From: vegiv...@gmail.com [mailto:vegiv...@gmail.com] On Behalf Of Johan De Meersman Sent: Thursday, June 03, 2010 6:52 AM To: je...@gii.co.jp Cc: mysql@lists.mysql.com Subject: Re: Slow when using sub-query The short answer is that the optimizer is amazingly stupid

how to avoid sub-query to gain performance

2010-06-02 Thread Lin Chun
*hi* * * *i have a reporting query which have 2 long sub-query* SELECT r1.code_centre, r1.libelle_centre, r1.id_equipe, r1.equipe, r1.id_file_attente, r1.libelle_file_attente,r1.id_date, r1.tranche, r1.id_granularite_de_periode,r1.granularite, r1.ContactsTraites, r1.ContactsenParcage, r1

Re: how to avoid sub-query to gain performance

2010-06-02 Thread Perrin Harkins
On Wed, Jun 2, 2010 at 10:28 AM, Lin Chun franks1...@gmail.com wrote: *don't know it very clear, but i think is the problem of derived seems it take full scaning* Yes, it has no indexes so it isn't good for very large subqueries. You should create them as temporary tables instead and give them

Slow when using sub-query

2010-06-02 Thread Jerry Schwartz
select_type: SIMPLE table: prod type: ref possible_keys: prod_pub_prod_id,pub_id,pub_id_2 key: pub_id key_len: 48 ref: const rows: 1543 Extra: Using where === Outer Query with Sub-query === us-gii EXPLAIN - SELECT prod_num FROM prod

Re: sub query or something else

2009-09-04 Thread Wolfgang Schaefer
sangprabv wrote: I have these query: SELECT SUM(price)*0.5 AS price1 FROM table WHERE partner = 'A'; SELECT SUM(price)*0.65 AS price2 FROM table WHERE partner = 'B'; Is it possible to make the queries into 1 single query? How to make it happen? Many thanks for helps. Willy You can

Re: sub query or something else

2009-09-04 Thread sangprabv
Many thanks for the query. It works ;) Willy On Fri, 2009-09-04 at 08:09 +0200, Wolfgang Schaefer wrote: sangprabv wrote: I have these query: SELECT SUM(price)*0.5 AS price1 FROM table WHERE partner = 'A'; SELECT SUM(price)*0.65 AS price2 FROM table WHERE partner = 'B'; Is it

Re: sub query or something else

2009-09-04 Thread sangprabv
Many thanks for your query, seems we need to group it like Wolfgang's does. Willy On Thu, 2009-09-03 at 22:33 -0700, Manasi Save wrote: may be you can use IN clause: SELECT SUM(price)*0.5 AS price1, SUM(price)*0.65 AS price2 FROM table WHERE partner IN ('A', 'B'); -- MySQL General

sub query or something else

2009-09-03 Thread sangprabv
I have these query: SELECT SUM(price)*0.5 AS price1 FROM table WHERE partner = 'A'; SELECT SUM(price)*0.65 AS price2 FROM table WHERE partner = 'B'; Is it possible to make the queries into 1 single query? How to make it happen? Many thanks for helps. Willy -- MySQL General Mailing List For

Re: sub query or something else

2009-09-03 Thread Robert Citek
It's not clear what exactly you are looking for. Two possible solutions: 1) use a union 2) use a join with another table containing partner and factor fields. Can you give a short example of what the input looks like and what you would like the output to look like? Regards, - Robert On Thu,

Re: sub query or something else

2009-09-03 Thread sangprabv
What I'm looking for is to SUM the price from partner A and B with each result. So the result I expect is like Partner A total's price 123, Partner B total's price 456. Can you give me the query example? TIA. Willy On Thu, 2009-09-03 at 23:11 -0400, Robert Citek wrote: It's not clear what

Re: sub query or something else

2009-09-03 Thread Colin Streicher
Because these are two quite distinct queries, I don't see an immediate way of joining them that would make them more efficient. Something that comes to mind are sub-select statements for example, but that would make this more complex than it needs to be. Like Robert said, you aren't giving us

Re: sub query or something else

2009-09-03 Thread Manasi Save
may be you can use IN clause: SELECT SUM(price)*0.5 AS price1, SUM(price)*0.65 AS price2 FROM table WHERE partner IN ('A', 'B'); -- Thanks and Regards, Manasi Save Artificial Machines Pvt Ltd. I have these query: SELECT SUM(price)*0.5 AS price1 FROM table WHERE partner = 'A'; SELECT

Re: Half Hour Sub-query in MySQL vs. 5 Seconds in VFP?

2009-06-22 Thread Matt Neimeyer
On Fri, Jun 19, 2009 at 11:27 AM, Brent Baisleybrentt...@gmail.com wrote: It sounds like you want to use spatial indexes, but they only became available in v4.1 http://dev.mysql.com/doc/refman/5.0/en/create-index.html http://dev.mysql.com/doc/refman/5.0/en/using-a-spatial-index.html That

Re: Half Hour Sub-query in MySQL vs. 5 Seconds in VFP?

2009-06-19 Thread Dan Nelson
In the last episode (Jun 18), Matt Neimeyer said: I'm converting a PHP app from using Visual FoxPro as the database backend to using MySQL as the backend. I'm testing on MySQL 4.1.22 on Mac OSX 10.4. The end application will be deployed cross platform and to both 4.x and 5.x MySQL servers.

Re: Half Hour Sub-query in MySQL vs. 5 Seconds in VFP?

2009-06-19 Thread Matt Neimeyer
SELECT zip FROM zipcodes WHERE degrees(acos(sin(radians(39.0788994))*sin(radians(latitude))+ cos(radians(39.0788994))*cos(radians(latitude))*cos(radians(-77.1227036-longitude*60*1.1515 5 Ouch.  You might want to calculate the rectange enclosing your target distance, add an index on lat

Re: Half Hour Sub-query in MySQL vs. 5 Seconds in VFP?

2009-06-19 Thread Brent Baisley
instantly. I'm at a complete loss... The suggestions I've seen online for optimizing Dependent Subquery's basically revolve around changing it from a sub-query to a join but that would require more re-architecturing than I want to do... (Unless I'm forced) Especially since more than a few of those

Re: Half Hour Sub-query in MySQL vs. 5 Seconds in VFP?

2009-06-19 Thread Peter Brawley
at a complete loss... The suggestions I've seen online for optimizing Dependent Subquery's basically revolve around changing it from a sub-query to a join but that would require more re-architecturing than I want to do... (Unless I'm forced) Especially since more than a few of those solutions suggested

Re: Half Hour Sub-query in MySQL vs. 5 Seconds in VFP?

2009-06-19 Thread Walter Heck - OlinData.com
Peter, On Thu, Jun 18, 2009 at 9:27 PM, Peter Brawleypeter.braw...@earthlink.net wrote: For explanation alternatives see The unbearable slowness of IN() at http://localhost/artful/infotree/queries.php. you prolly meant to not post a url pointing at your local copy of your website. This works

Half Hour Sub-query in MySQL vs. 5 Seconds in VFP?

2009-06-18 Thread Matt Neimeyer
for optimizing Dependent Subquery's basically revolve around changing it from a sub-query to a join but that would require more re-architecturing than I want to do... (Unless I'm forced) Especially since more than a few of those solutions suggested precalculating the distance between zipcodes which

Re: Half Hour Sub-query in MySQL vs. 5 Seconds in VFP?

2009-06-18 Thread Johnny Withers
it from a sub-query to a join but that would require more re-architecturing than I want to do... (Unless I'm forced) Especially since more than a few of those solutions suggested precalculating the distance between zipcodes which only works if the distances are known (only allow 10, 50 and 100 mile

sub query help

2008-08-18 Thread Paul Nowosielski
Dear All, I am interested in performing a sub query that removes duplicate records from a temporary table prior to pushing the data to the main table. I am not sure if it is possible and thought I would ask prior to the endeavor. I currently use php to perform this operation but is really bogs

Sub query help

2007-05-16 Thread Brian Menke
. This runs flawlessly in EMS SQL MANAGER and produces what I want. But of course when I try to use it as a query in my PHP as the select statement, it bombs. I think the answer is to create a sub query, but I can't seem to find a good example on the web anywhere. Maybe I am just not using the right

Re: Sub query help

2007-05-16 Thread Brent Baisley
: Wednesday, May 16, 2007 7:25 PM Subject: Sub query help MySQL Version 5.0.22 I would be thrilled if someone could even just point me to a site that provided good examples of using sub queries. I have the following query: SELECT participants.store_id, completed_modules.module_id, AVG

Re: Sub query help

2007-05-16 Thread Peter Brawley
Brian, I think the answer is to create a sub query, Without your tables I can't test this transcription, but the trick is straightforward: if the first query includes the column(s) required to join it correctly to the 2nd query, replace the avgscore table reference in the second query

Re: Trouble with using IN for a sub-query statement

2006-08-17 Thread Michael Stassen
Chris wrote: Chris White wrote: On Monday 07 August 2006 12:13 pm, William DeMasi wrote: I meant to have it say : select * from c2iedm_dev2.act where act_id IN (select obj_act_id from c2iedm_dev2.act_functl_assoc where subj_act_id =24); What does the output of (the subselect): select

Trouble with using IN for a sub-query statement

2006-08-07 Thread William DeMasi
The select statement I am trying to run is: select * from c2iedm_dev2.act where act_id =(select obj_act_id from c2iedm_dev2.act_functl_assoc where subj_act_id =24); But I get the error below: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for

Re: Trouble with using IN for a sub-query statement

2006-08-07 Thread Chris White
On Monday 07 August 2006 12:02 pm, William DeMasi wrote: The select statement I am trying to run is: select * from c2iedm_dev2.act where act_id =(select obj_act_id from c2iedm_dev2.act_functl_assoc where subj_act_id =24); Well the problem I'm seeing is that you're not using IN anywhere in the

Re: Trouble with using IN for a sub-query statement

2006-08-07 Thread Chris White
On Monday 07 August 2006 12:13 pm, William DeMasi wrote: I meant to have it say : select * from c2iedm_dev2.act where act_id IN (select obj_act_id from c2iedm_dev2.act_functl_assoc where subj_act_id =24); What does the output of (the subselect): select obj_act_id from

Re: Trouble with using IN for a sub-query statement

2006-08-07 Thread Chris
Chris White wrote: On Monday 07 August 2006 12:13 pm, William DeMasi wrote: I meant to have it say : select * from c2iedm_dev2.act where act_id IN (select obj_act_id from c2iedm_dev2.act_functl_assoc where subj_act_id =24); What does the output of (the subselect): select obj_act_id from

Sub-query optimizer improvements scheduled?

2006-05-06 Thread Peter Rosenthal
Out of interest is there any time on the roadmap to improve the query optimizer's handling of sub-queries as specified in http://dev.mysql.com/doc/refman/5.0/en/subquery-restrictions.html ? Thanks.

Re: Sub-query optimizer improvements scheduled?

2006-05-06 Thread Jim Winstead
On Sat, May 06, 2006 at 12:55:55PM +0100, Peter Rosenthal wrote: Out of interest is there any time on the roadmap to improve the query optimizer's handling of sub-queries as specified in http://dev.mysql.com/doc/refman/5.0/en/subquery-restrictions.html ? As Timour previewed at his Speeding Up

Re: need help with user variables in where clause of sub query

2005-12-29 Thread Dan Rossi
of the current primary key field top a sub query ! Read my latest post if i can get around not using variables, and still manage to get the right values of a current row going to a sub query ? On 29/12/2005, at 2:48 AM, [EMAIL PROTECTED] wrote: You seem to be coming at SQL with a COBOL

Re: need help with user variables in where clause of sub query

2005-12-29 Thread SGreen
Dan Rossi [EMAIL PROTECTED] wrote on 12/29/2005 07:19:13 AM: Thanks for your kind words of opinion, if you feel you have a better way please do go ahead , i am going to show you the sql i ended up using which was a union to append the current summary at the end, i then had to use php

Re: need help with user variables in where clause of sub query

2005-12-28 Thread SGreen
not a working query, and im not asking for someone to fix it, however as u can see i need to send the customerID and month to the sub query. What its actually trying to do is tedious to explain, but i have two tables of media usage for a customer, the current month will be in the usage table, so

Re: need help with user variables in where clause of sub query

2005-12-28 Thread Dan Rossi
not a working query, and im not asking for someone to fix it, however as u can see i need to send the customerID and month to the sub query. What its actually trying to do is tedious to explain, but i have two tables of media usage for a customer, the current month will be in the usage table, so

Re: need help with user variables in where clause of sub query

2005-12-28 Thread Dan Rossi
Btwi dont want the column of a view to be a variable, i think thats what it thinks ! Im just needing to send the value of the current primary key field top a sub query ! Read my latest post if i can get around not using variables, and still manage to get the right values of a current row

Re: need help with user variables in where clause of sub query

2005-12-28 Thread Dan Rossi
the column of a view to be a variable, i think thats what it thinks ! Im just needing to send the value of the current primary key field top a sub query ! Read my latest post if i can get around not using variables, and still manage to get the right values of a current row going to a sub query

Re: need help with user variables in where clause of sub query

2005-12-28 Thread SGreen
instead of making variables but it didnt even let me do this snip On 29/12/2005, at 3:31 PM, Dan Rossi wrote: Btwi dont want the column of a view to be a variable, i think thats what it thinks ! Im just needing to send the value of the current primary key field top a sub query

need help with user variables in where clause of sub query

2005-12-27 Thread Dan Rossi
Hi there i am trying to use usewr variables in a select statement to add to a where clause in a sub query. Ie select @id:=id,@month:=month, (select SUM(totals) from table where [EMAIL PROTECTED] and [EMAIL PROTECTED]) as totals from table its happened on other occasions ie with calculations

Re: need help with user variables in where clause of sub query

2005-12-27 Thread SGreen
Dan Rossi [EMAIL PROTECTED] wrote on 12/27/2005 11:39:57 PM: Hi there i am trying to use usewr variables in a select statement to add to a where clause in a sub query. Ie select @id:=id,@month:=month, (select SUM(totals) from table where [EMAIL PROTECTED] and [EMAIL PROTECTED]) as totals

Re: need help with user variables in where clause of sub query

2005-12-27 Thread Dan Rossi
to the sub query. What its actually trying to do is tedious to explain, but i have two tables of media usage for a customer, the current month will be in the usage table, so that if the plan changes in that month so does the totals, but for the previous months there is a static month_totals table

Sub Query

2005-11-14 Thread Herman Scheepers
Hi Could anyone help perhaps tell me why the following simple query containing a sub-query gives a syntax error. select 1 from messages where not exists ( select 1 from message_push_notifications where message_id = messages.id) Thanx Herman

Re: Sub Query

2005-11-14 Thread SGreen
Herman Scheepers [EMAIL PROTECTED] wrote on 11/13/2005 11:53:23 AM: Hi Could anyone help perhaps tell me why the following simple query containing a sub-query gives a syntax error. select 1 from messages where not exists ( select 1 from message_push_notifications

Re: Sub Query

2005-11-14 Thread Rhino
Scheepers [EMAIL PROTECTED] To: mysql@lists.mysql.com Sent: Sunday, November 13, 2005 11:53 AM Subject: Sub Query Hi Could anyone help perhaps tell me why the following simple query containing a sub-query gives a syntax error. select 1 from messages where not exists ( select 1 from

Re: Sub Query

2005-11-14 Thread Gleb Paharenko
anyone help perhaps tell me why the following simple query containing a sub-query gives a syntax error. select 1 from messages where not exists ( select 1 from message_push_notifications where message_id = messages.id) Thanx Herman

Re: Sub Query to long...

2005-05-25 Thread mfatene
I rerezad you and discovered that (BrgId, Kode) is UNIQUE. your query will return no rows :o) spending 54813 ms for nothing. Mathias Selon [EMAIL PROTECTED]: Hi, You may have the same table structure in MS, but not the same table definiton : constraints+indexes+stats ! try : create

Re: Sub Query to long...

2005-05-25 Thread mfatene
hi, don't listen to last email. since the two first rows are unique, you can't use my example. Just create an index as i said, and play your query : Select BrgId, Kode, Barang From Barang Where Barang in (Select Barang From Barang Group By Barang Having Count(*) 1 ) Mathias Selon [EMAIL

Re: Sub Query to long...

2005-05-25 Thread Hendro Suryawan
Hi Mathias, Thanks for your suggestion, but i run this query to find multiple records with the same name in field barang (double records). And the results i found 94 rows at 54813 ms. I try your idea and the result is the same. So i think mysql not optimized for this kind sub query. Do you

Re: Sub Query to long...

2005-05-25 Thread SGreen
is the same. So i think mysql not optimized for this kind sub query. Do you have any other suggestion? hendro [EMAIL PROTECTED] wrote: hi, don't listen to last email. since the two first rows are unique, you can't use my example. Just create an index as i said, and play your query

Re: Sub Query to long...[solved]

2005-05-25 Thread Hendro Suryawan
[EMAIL PROTECTED] wrote: My suggestion: Don't use a subquery, use a temp table ( http://dev.mysql.com/doc/mysql/en/rewriting-subqueries.html) CREATE TEMPORARY TABLE tmpDupes (KEY (`Barang`)) SELECT `Barang` FROM Barang GROUP BY Barang HAVING count(1) 1; Select b.`BrgId`, b.`Kode`, b.`Barang`

Re: complicated query | no Sub query

2005-05-24 Thread Anoop kumar V
Thanks Peter - you gave me some ideas... here is what I have so far (simplified for simplification..) select t2.dt_aud_rec, t1.id_secr_rqst from isr2_aud_log t1, isr2_aud_log t2 where t1.id_secr_rqst=t2.id_secr_rqst and t1.dt_aud_rec t2.dt_aud_rec group by t1.id_secr_rqst but the problem is

Re: complicated query | no Sub query

2005-05-24 Thread SGreen
Anoop kumar V [EMAIL PROTECTED] wrote on 05/24/2005 03:02:11 PM: Thanks Peter - you gave me some ideas... here is what I have so far (simplified for simplification..) select t2.dt_aud_rec, t1.id_secr_rqst from isr2_aud_log t1, isr2_aud_log t2 where t1.id_secr_rqst=t2.id_secr_rqst and

Re: complicated query | no Sub query

2005-05-24 Thread Anoop kumar V
My profound apologies here is the table create structure. the biggest problem i think is that this table does not have any primary keys or atleast unique columns: (I think joins require unique columns) mysql show create table isr2_aud_log\G *** 1. row

Sub Query to long...

2005-05-24 Thread Hendro Suryawan
Hi, I have 8414 records in table name Barang, I run query like this : Select BrgId, Kode, Barang From Barang Where Barang in (Select Barang From Barang Group By Barang Having Count(*) 1 ) and the answer took 54813 ms. I think is too long. I ran the same query against same table in MS SQL

Re: Sub Query to long...

2005-05-24 Thread mfatene
Hi, You may have the same table structure in MS, but not the same table definiton : constraints+indexes+stats ! try : create index toto on Barang(BrgId, Kode, Barang); Select BrgId, Kode, Barang From Barang Group By Barang Having Count(*) 1 ; Mathias Selon Hendro Suryawan [EMAIL

complicated query | no Sub query

2005-05-23 Thread Anoop kumar V
hi All, I need to create a query using no subqueries as I use 4.0.23 which does not support subqueries. I cannot upgrade for some compellimg reasons (the product does not support anything later than 4.0.23nt as of now). I also cannot use any thing that is native to mysql - in the sense that

RE: complicated query | no Sub query

2005-05-23 Thread Peter Normann
Hi Anoop Try: SELECT t1.id_secr_rqst, t2.name_rec_type, t1.dt_aud_rec FROM isr2_aud_log t1, isr2_aud_log t2 WHERE t1.id_secr_rqst = t2.id_secr_rqst AND t1.name_rec_type='Exception Resource' ORDER by t1.dt_aud_rec DESC LIMIT 2; Peter Normann -- MySQL General Mailing List For list archives:

Re: complicated query | no Sub query

2005-05-23 Thread Anoop kumar V
Thanks Peter - but I see two issues: 1. It returns data about only one id_secr_rqst - I want it to return data about every id_secr_rqst in the table. 2. Limit IMO is mysql specific (I hope I am wrong) is there something generic so I dont need to bother about which database I am running it

RE: complicated query | no Sub query

2005-05-23 Thread Peter Normann
Anoop kumar V mailto:[EMAIL PROTECTED] wrote: 1. It returns data about only one id_secr_rqst - I want it to return data about every id_secr_rqst in the table. So, if I understand you correctly (sorry, having a bad day), you want all records for the past two days? Assuming this, you could use

RE: complicated query | no Sub query

2005-05-23 Thread Peter Normann
Anoop kumar V mailto:[EMAIL PROTECTED] wrote: well - actually it might not be the last 2 days - i just want 2 of the latest records for every task regardless of what date it is in the table. Okay, now I think I understand what you need - and if I am correct, this looks like one of the more

Re: Lost connection to Mysql server during query using a group by clause and sub query

2005-05-19 Thread Ware Adams
On May 19, 2005, at 12:51 AM, Dan Rossi wrote: Hi there, I am having issues with this funny error message. I am trying to do a sub query and then a group by clause on a date. However i keep getting this annoying message for some reason. Happens via terminal aswell as my sql gui. Here

Lost connection to Mysql server during query using a group by clause and sub query

2005-05-18 Thread Dan Rossi
Hi there, I am having issues with this funny error message. I am trying to do a sub query and then a group by clause on a date. However i keep getting this annoying message for some reason. Happens via terminal aswell as my sql gui. Here is the query I am trying to do select (select count

Sub Query question

2005-02-10 Thread Daniel Rossi
Hi there, I was wondering if its possible to be able to send a field from the outer table to be used as the where statement for the sub query ? something like this select somefield from table 1, (select count(*) from table2 inner join table1 using somekey where table1.key=somefield) as alias

Sub query again

2005-02-10 Thread daniel
I have worked out, to send that field to the where query, i have to select the outer table again !! i dont think this is very efficient ? select * from complaints, (SELECT IF (count(*) 1,Yes,No) AS count FROM complainant ccINNER JOIN complaints c ON cc.complainantID=c.complainantID WHERE

Sub query Help

2005-01-31 Thread Gustafson, Tim
to fix the problem, but I can't just change that overall query: remember, this is in a report generator, and arguably a simple one at that. I have to fit everything I need to do into the column sub queries. Is this possible? Is there any way to modify the sub query so that it will include all

Re: sub query is extermely slow

2005-01-20 Thread sam wun
[EMAIL PROTECTED] wrote: SELECT DISTINCT i.basename FROM inventory i INNER JOIN transaction t ON i.prodcode = t.prodcode AND t.date = '2004-01-01' AND t.date = '2004-01-31' INNER JOIN transaction tt ON i.prodcode = tt.prodcode AND tt.date = '2005-01-01'

Re: sub query is extermely slow

2005-01-20 Thread SGreen
sam wun [EMAIL PROTECTED] wrote on 01/20/2005 11:45:40 AM: [EMAIL PROTECTED] wrote: SELECT DISTINCT i.basename FROM inventory i INNER JOIN transaction t ON i.prodcode = t.prodcode AND t.date = '2004-01-01' AND t.date = '2004-01-31' INNER JOIN

sub query is extermely slow

2005-01-19 Thread sam wun
Hi list, The following sql statement takes 3 mintues to complete the query. How can I improve its speed? select DISTINCT i.basename from inventory i, transaction t, customer c where i.prodcode = t.prodcode and c.custcode = t.custcode and i.basename is not NULL and i.prodname is not NULL and

RE: sub query is extermely slow

2005-01-19 Thread Clint Edwards
Sam, Can you send the output of the following: #explain your query\G Clint From: sam wun [EMAIL PROTECTED] To: mysql@lists.mysql.com Subject: sub query is extermely slow Date: Wed, 19 Jan 2005 20:02:37 +0800 Hi list, The following sql statement takes 3 mintues to complete the query. How can I

Re: sub query is extermely slow

2005-01-19 Thread sam wun
From: sam wun [EMAIL PROTECTED] To: mysql@lists.mysql.com Subject: sub query is extermely slow Date: Wed, 19 Jan 2005 20:02:37 +0800 Hi list, The following sql statement takes 3 mintues to complete the query. How can I improve its speed? select DISTINCT i.basename from inventory i, transaction t

Re: sub query is extermely slow

2005-01-19 Thread Clint Edwards
'%buffer%';: Clint From: sam wun [EMAIL PROTECTED] To: Clint Edwards [EMAIL PROTECTED] CC: mysql@lists.mysql.com Subject: Re: sub query is extermely slow Date: Wed, 19 Jan 2005 20:39:41 +0800 Clint Edwards wrote: Sam, Can you send the output of the following: #explain your query\G Thanks

Re: sub query is extermely slow

2005-01-19 Thread Clint Edwards
] To: Clint Edwards [EMAIL PROTECTED] CC: mysql@lists.mysql.com Subject: Re: sub query is extermely slow Date: Wed, 19 Jan 2005 22:05:58 +0800 Clint Edwards wrote: Sam, Can you send the following information: When was the last time 'analyze table table_name' (inventory, transaction, customer

Re: sub query is extermely slow

2005-01-19 Thread sam wun
index to a field after a table is created? Thanks Sam Clint From: sam wun [EMAIL PROTECTED] To: Clint Edwards [EMAIL PROTECTED] CC: mysql@lists.mysql.com Subject: Re: sub query is extermely slow Date: Wed, 19 Jan 2005 22:05:58 +0800 Clint Edwards wrote: Sam, Can you send the following information

RE: sub query is extermely slow

2005-01-19 Thread Artem Koltsov
Check ALTER statement in MySQL doc. It explains how to add/modify an index after a table has been created. -Original Message- From: sam wun [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 19, 2005 10:00 AM Cc: mysql@lists.mysql.com Subject: Re: sub query is extermely slow

Re: sub query is extermely slow

2005-01-19 Thread SGreen
sam wun [EMAIL PROTECTED] wrote on 01/19/2005 07:02:37 AM: Hi list, The following sql statement takes 3 mintues to complete the query. How can I improve its speed? select DISTINCT i.basename from inventory i, transaction t, customer c where i.prodcode = t.prodcode and c.custcode =

RE: sub query is extermely slow

2005-01-19 Thread Andy Eastham
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 19 January 2005 15:04 To: sam wun Cc: mysql@lists.mysql.com Subject: Re: sub query is extermely slow sam wun [EMAIL PROTECTED] wrote on 01/19/2005 07:02:37 AM: Hi list, The following sql statement

Re: sub query is extermely slow

2005-01-19 Thread sam wun
[EMAIL PROTECTED] wrote: I would simplify it by converting everything to us explicit (not implicit) JOIN statements,skipping unnecessary type conversions, and logically merging your conditions. Here is your original query, slightly reformatted. SELECT DISTINCT i.basename FROM inventory i,

Re: Sub query on mySQL 4.0.18

2004-06-04 Thread Prabu Subroto
Oooo...Oo. thank you very much for you information. I better migrate my database to postgres. I'll use MySQL back after MySQL 4.1 stable version released on SuSE Distro. --- Jigal van Hemert [EMAIL PROTECTED] wrote: I don#t understand why subquery on my MySQL 4.0.18-Mas does not valid.

Sub query on mySQL 4.0.18

2004-06-02 Thread Prabu Subroto
Dear my friends... I don#t understand why subquery on my MySQL 4.0.18-Mas does not valid. Here what I have done. [EMAIL PROTECTED]:~ mysql -h 192.168.23.1 -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 354744 to server version:

Re: Sub query on mySQL 4.0.18

2004-06-02 Thread Jigal van Hemert
I don#t understand why subquery on my MySQL 4.0.18-Mas does not valid. Simple reason: v. 4.0.18 does not support subqueries yet. Use 4.1 or later. Regards, Jigal. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL

Re: Sub query on mySQL 4.0.18

2004-06-02 Thread Michael Stassen
Jigal van Hemert wrote: I don#t understand why subquery on my MySQL 4.0.18-Mas does not valid. select * from salesreport where custid in (select custid from appointment where done='N'); Simple reason: v. 4.0.18 does not support subqueries yet. Use 4.1 or later. Regards, Jigal. Or, rewrite the

Re: Limit in sub-query - when can we expect it?

2004-05-08 Thread Terry Riley
Also interested in answer to this one. Terry Riley --Original Message- Hi List, When can we expect limits in sub-queries? I am currently on 4.1.0. 1235 - This version of MySQL doesn't yet support 'LIMIT IN/ALL/ANY/SOME subquery' Query: -- MySQL General

Limit in sub-query - when can we expect it?

2004-05-06 Thread Terence
Hi List, When can we expect limits in sub-queries? I am currently on 4.1.0. 1235 - This version of MySQL doesn't yet support 'LIMIT IN/ALL/ANY/SOME subquery' Query: -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL

Re: sub-query

2004-03-05 Thread Egor Egorov
the rows of the UNION sub-query there.. the reason I used it as sub-query is that I want to count the rows, and then use: SELECT FOUND_ROWS(); to get the number of rows supposed to be retuned without using the LIMIT.. Is all above correct? First of all your subqueries are illegal, because you

sub-query

2004-03-03 Thread Lorderon
Since I don't use MySQL 4.1, is this query OK? SELECT SQL_CALC_FOUND_ROWS * FROM ((SELECT * FROM t1 WHERE id100 GROUP BY country) UNION ALL (SELECT * FROM t2 WHERE id150 GROUP BY country) LIMIT 0,10); I want this to return all the rows of the UNION sub-query

Removing sub-query

2004-01-23 Thread Michael McTernan
Hi there, I'm using MySQL 4.0.15 on RedHat 9.0. I've got problem for which I can't figure out how to do it efficiently without using a subquery. 4.1.0 isn't really an option since this is going into a stable environment. The table is like this. +--+--++ | revision | id |

sub query format...

2003-12-03 Thread Chris Knipe
Lo all, What's the format for a sub query in MySQL?? I've tried the below with a few variants but I can't seem to get it sorted... SELECT songlist.ID AS ID, songlist.duration AS Duration, songlist.artist AS Artist, songlist.title AS Title, songlist.filename

Re: sub query format...

2003-12-03 Thread Daniel Kasak
Chris Knipe wrote: Lo all, What's the format for a sub query in MySQL?? I've tried the below with a few variants but I can't seem to get it sorted... SELECT songlist.ID AS ID, songlist.duration AS Duration, songlist.artist AS Artist, songlist.title AS Title

MySQL sub-query error.

2003-11-05 Thread Geeta Rajaraman
Good Morning everyone: I need help figuring out what is wrong with this query. I have tried to use the LEFT JOIN, but it doesn't solve the purpose. This is what I am trying to run: SELECT group_id,name,'SELECTED' FROM groups WHERE group_id = (SELECT group_id FROM user_groups WHERE

RE: MySQL sub-query error.

2003-11-05 Thread Chris
: SELECT group_id, name, IF(1=userid,'SELECTED',' ') FROM groups ORDER BY group_id Chris -Original Message- From: Geeta Rajaraman [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 7:03 AM To: [EMAIL PROTECTED] Subject: MySQL sub

RE: MySQL sub-query error.

2003-11-05 Thread Chris
[mailto:[EMAIL PROTECTED] Sent: Wednesday, November 05, 2003 10:00 AM To: Chris Subject: Re: MySQL sub-query error. See..I changed it = only coz the IN wouldn't work. I am guessing its a MySQL version issue. I am using a version below 4.0. I am curious about the second version of my query you

  1   2   >