Re: Query Optimization

2011-08-10 Thread Jan Steinman
From: Brandon Phelps bphe...@gls.com I am curious if there is any way I can better optimize the below query, as currently it takes this query around 10 seconds to run but I am sure this will get slower and slower as the database grows. You need an index on `close_dt`. SELECT

Re: Query bug

2011-07-24 Thread Johnny Withers
What's your vb code for outputting the results look like? On Jul 24, 2011 8:22 AM, Velen Vydelingum ve...@biz-mu.com wrote: Hi, I have the following query which is fine when I run it from the mysql shell screen: select supplier_code,0,0,0,0,0-sum(amountpaid),0 from custpayments where

Re: Query bug

2011-07-24 Thread Velen Vydelingum
- From: Johnny Withers joh...@pixelated.net To: Velen Vydelingum ve...@biz-mu.com Cc: mysql@lists.mysql.com Sent: Sunday, July 24, 2011 17:41 Subject: Re: Query bug What's your vb code for outputting the results look like? On Jul 24, 2011 8:22 AM, Velen Vydelingum ve...@biz-mu.com wrote: Hi

Re: query for twin primes

2011-07-14 Thread Simcha Younger
On Wed, 13 Jul 2011 12:26:02 -0600 Elim Qiu elim@gmail.com wrote: I have a prime table what the query will be if i like to find all rows where pv+2's are also in colum 'pv', where oid 100? In other words, how to get the list of yonger brother of the twin primes within certain

Re: query for twin primes

2011-07-13 Thread shawn wilson
On Jul 13, 2011 2:26 PM, Elim Qiu elim@gmail.com wrote: I have a prime table +-+--+-+ | oid | pv | descipt | +-+--+-+ | 1 |2 | NULL| | 2 |3 | NULL| | 3 |5 | NULL| | 4 |7 | NULL| | 5 | 11 | NULL| |

Re: query for twin primes

2011-07-13 Thread mos
At 01:26 PM 7/13/2011, you wrote: I have a prime table +-+--+-+ | oid | pv | descipt | +-+--+-+ | 1 |2 | NULL| | 2 |3 | NULL| | 3 |5 | NULL| | 4 |7 | NULL| | 5 | 11 | NULL| | .|

Re: query for twin primes

2011-07-13 Thread Elim Qiu
How about: select  t1.pv, t2.pv from prime t1, prime t2 where t2.pv=t1.pv+2 and t1.oid100 order by t2.pv Mike Very nice and simple. Thanks Mike! Also Thanks Singer X.J. Wang and shawn wilson. best regards, Elim -- MySQL General Mailing List For list archives:

Re: Query on wait_timeout

2011-06-16 Thread Suresh Kuna
Try this out:-) Below are the steps to generate a deadlock so that the behaviour of a deadlock can be illustrated: -- 1) Create Objects for Deadlock Example USE TEMPDB CREATE TABLE dbo.foo (col1 INT) INSERT dbo.foo SELECT 1 CREATE TABLE dbo.bar (col1 INT) INSERT dbo.bar SELECT 1 -- 2) Run in

Re: Query on wait_timeout

2011-06-16 Thread Adarsh Sharma
Thanks Suresh but I find it very difficult to implement it :- Suresh Kuna wrote: Try this out:-) Below are the steps to generate a deadlock so that the behaviour of a deadlock can be illustrated: -- 1) Create Objects for Deadlock Example USE TEMPDB Is I have to create temdb database as

RE: Query on wait_timeout

2011-06-16 Thread Martin Gainty
@lists.mysql.com Subject: Re: Query on wait_timeout Thanks Suresh but I find it very difficult to implement it :- Suresh Kuna wrote: Try this out:-) Below are the steps to generate a deadlock so that the behaviour of a deadlock can be illustrated: -- 1) Create Objects for Deadlock Example

Re: Query on wait_timeout

2011-06-16 Thread Claudio Nanni
Just a little side note, The table engine needs to be InnoDB or the transaction will not have effect, The behavior may differs also according to the isolation level, That will apply a lock on all records because no where is specified, which its not very common. Regards, Claudio On Jun 16, 2011

Re: Query on wait_timeout

2011-06-15 Thread Suresh Kuna
Good question Yogesh, I can say the best solution is Create a deadlock and test it, you will come to know more about it. On Wed, Jun 15, 2011 at 3:38 PM, Yogesh Kore yogeshk...@gmail.com wrote: Hi, Small doubt for wait_timeout. If my wait_timeout is set for 180 seconds and if any deadlock

Re: Query on wait_timeout

2011-06-15 Thread Adarsh Sharma
How we can create a deadlock manually to test this problem. Thanks Suresh Kuna wrote: Good question Yogesh, I can say the best solution is Create a deadlock and test it, you will come to know more about it. On Wed, Jun 15, 2011 at 3:38 PM, Yogesh Kore yogeshk...@gmail.com wrote: Hi,

Re: Query help

2011-03-02 Thread Claudio Nanni
Hi Neil, select login_id, ip_address from basic_table group by login_id,ip_address having count(login_id,ip_address)1 this should work in case you want to see also the list of emails add: group_concat(email_address,',') as list_of_used_emails to the select fields. Claudio

RE: Query help

2011-03-02 Thread Jerry Schwartz
-Original Message- From: Tompkins Neil [mailto:neil.tompk...@googlemail.com] Sent: Wednesday, March 02, 2011 6:00 AM To: [MySQL] Subject: Query help Hi I've the following basic table login_id email_address ip_address I want to extract all records from this table in which a user has

Re: Query help

2011-03-02 Thread Tompkins Neil
Thanks for the response. This is what I was after. Although, I am looking to find out the email addresses used to login from the same IP ? On Wed, Mar 2, 2011 at 2:49 PM, Jerry Schwartz je...@gii.co.jp wrote: -Original Message- From: Tompkins Neil

RE: Query help

2011-03-02 Thread Jerry Schwartz
...@googlemail.com] Sent: Wednesday, March 02, 2011 10:12 AM To: Jerry Schwartz Cc: [MySQL] Subject: Re: Query help Thanks for the response. This is what I was after. Although, I am looking to find out the email addresses used to login from the same IP ? On Wed, Mar 2, 2011 at 2:49 PM, Jerry

Re: Query Stored Index instead of Group By

2010-12-20 Thread Feris Thia
Hi Johan, On Sun, Dec 19, 2010 at 7:11 PM, Johan De Meersman vegiv...@tuxera.bewrote: You can't query the index directly, but if you select only fields that are in the index, no table lookups will be performed - this is called a covering index. Great.. Thanks for the confirmation. Regards,

Re: Query Stored Index instead of Group By

2010-12-19 Thread Johan De Meersman
On Sun, Dec 19, 2010 at 3:19 AM, Feris Thia milis.datab...@phi-integration.com wrote: Hi Everyone, Is there a way to query values stored in our index instead of using group by selection which will produce same results ? You can't query the index directly, but if you select only fields that

Re: Query Help

2010-10-27 Thread Shawn Green (MySQL)
On 10/27/2010 6:55 AM, Nuno Mendes wrote: I have 3 tables: (1) Companies, (2) locations and (3) employees: CREATE TABLE `companies` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(75) NOT NULL, UNIQUE KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 CREATE TABLE `locations ` ( `id`

Re: Query precision issue

2010-10-25 Thread Carlos Proal
Thats because float columns store approximate data values, you may need to use an error range in comparison, or at your own discretion use the decimal data type. You can get more info in: http://dev.mysql.com/doc/refman/5.1/en/numeric-types.html

Re: Query precision issue

2010-10-25 Thread Dan Nelson
In the last episode (Oct 25), Sairam Krishnamurthy said: I have simple query like 'select * from table1 where column1=-107.689878'. This returns an empty set. But there is data corresponding to this value of column. When I looked more into it, it seems like a precision issue. The

Re: Query precision issue

2010-10-25 Thread Sairam Krishnamurthy
That is exactly the problem. It is float. Thanks for your input. Thanks, Sairam Krishnamurthy +1 612 859 8161 On 10/25/2010 01:00 PM, Dan Nelson wrote: In the last episode (Oct 25), Sairam Krishnamurthy said: I have simple query like 'select * from table1 where column1=-107.689878'.

Re: Query precision issue

2010-10-25 Thread Joerg Bruehe
Sairam, sorry to be so blunt, and please don't feel offended: Sairam Krishnamurthy wrote: [[...]] Can somebody help me to find out the problem? I can very well truncate the trailing zeros when querying, but I am interested in finding why an additional trailing zero returns an empty set.

Re: Query conditions

2010-09-10 Thread Michael Dykman
It's about syntax and clarity, both for the reader and to the query optimizer. The JOIN conditions belong in the ON sub-statement precisely because they are the predicate for the join and serve to grow the data set .. the WHERE query is supposed to specify limiting conditions on that superset.

Re: Query SUM help

2010-09-09 Thread Ananda Kumar
did u try to use LIMIT after ORDER BY On Thu, Sep 9, 2010 at 1:27 PM, Tompkins Neil neil.tompk...@googlemail.comwrote: Any help would be really appreciated ? -- Forwarded message -- From: Tompkins Neil neil.tompk...@googlemail.com Date: Wed, Sep 8, 2010 at 5:30 PM

Re: Query SUM help

2010-09-09 Thread Tompkins Neil
Yes, but it doesn't work. Basically I want the SUM(players_master.rating) only to SUM the top 11 players from each team. Any suggestions ? Cheers Neil On Thu, Sep 9, 2010 at 9:17 AM, Ananda Kumar anan...@gmail.com wrote: did u try to use LIMIT after ORDER BY On Thu, Sep 9, 2010 at 1:27

Re: Query SUM help

2010-09-09 Thread Ananda Kumar
try using the RANK function... something like select * from table order by RANK desc limit 11.this will get u the top 11 rows. regards anandkl On Thu, Sep 9, 2010 at 1:55 PM, Tompkins Neil neil.tompk...@googlemail.comwrote: Yes, but it doesn't work. Basically I want the

RE: Query SUM help

2010-09-09 Thread Travis Ard
MySQL doesn't have the windowing functions that some other databases provide, but you can probably achieve the same effect with a couple user-defined variables: select teams_id as my_teams_id ,sum(rating) as total_team_rating from (select players.teams_id ,players.players_id

Re: Query help

2010-09-06 Thread Ananda Kumar
Tompkins, Which field stores the result of matches. regards anandkl On Mon, Sep 6, 2010 at 4:45 PM, Tompkins Neil neil.tompk...@googlemail.comwrote: Hi, I've the following fields within a table : fixtures_results_id home_teams_id away_teams_id home_goals away_goals home_users_id

Re: Query help

2010-09-06 Thread Tompkins Neil
These two fields home_goals and away_goals Cheers Neil On Mon, Sep 6, 2010 at 12:58 PM, Ananda Kumar anan...@gmail.com wrote: Tompkins, Which field stores the result of matches. regards anandkl On Mon, Sep 6, 2010 at 4:45 PM, Tompkins Neil neil.tompk...@googlemail.com wrote: Hi,

Re: Query help

2010-09-06 Thread Ananda Kumar
Also, can u please lets u know the value's in this table. Just one row, an example would do. regards anandkl On Mon, Sep 6, 2010 at 5:35 PM, Tompkins Neil neil.tompk...@googlemail.comwrote: These two fields home_goals and away_goals Cheers Neil On Mon, Sep 6, 2010 at 12:58 PM,

Re: Query help

2010-09-06 Thread Tompkins Neil
For sure here is some sample data home_teams_id,away_teams_id,home_goals,away_goals,home_users_id,away_users_id 100,200,2,1,5,6 200,100,1,1,6,5 Here is two rows of data for the same fixture both home and away Let me know if you need any more info. Cheers Neil On Mon, Sep 6, 2010 at 1:08 PM,

Re: query help

2010-08-21 Thread Travis Ard
Something like this might work: insert into domains select a.accountid, reverse(a.domainid), a.mailname from domains a left outer join domains b on b.domainid = reverse(a.domainid) and b.accountid = a.accountid and b.mailname = a.mailname where b.domainid is null; -Travis

RE: query results group/summed by interval

2010-08-01 Thread nuno . tavares
responsabilité pour le contenu fourni. Date: Sat, 31 Jul 2010 10:31:43 +0700 From: cuong.m...@vienthongso.com To: ave...@yahoo-inc.com CC: mustafa...@gmail.com; mysql@lists.mysql.com Subject: Re: query results group/summed by interval Hi Aveek, I think Ghulam just

RE: query results group/summed by interval

2010-08-01 Thread Travis Ard
Date: Sun, 1 Aug 2010 13:16:36 +0100 From: nuno.tava...@dri.pt To: mgai...@hotmail.com CC: cuong.m...@vienthongso.com; ave...@yahoo-inc.com; mustafa...@gmail.com; mysql@lists.mysql.com Subject: RE: query results group/summed by interval Hi all

RE: query results group/summed by interval

2010-07-31 Thread Martin Gainty
. Date: Sat, 31 Jul 2010 10:31:43 +0700 From: cuong.m...@vienthongso.com To: ave...@yahoo-inc.com CC: mustafa...@gmail.com; mysql@lists.mysql.com Subject: Re: query results group/summed by interval Hi Aveek, I think Ghulam just want to count calls for each intervals so the query should looks

RE: query results group/summed by interval

2010-07-31 Thread Martin Gainty
. Date: Sat, 31 Jul 2010 10:31:43 +0700 From: cuong.m...@vienthongso.com To: ave...@yahoo-inc.com CC: mustafa...@gmail.com; mysql@lists.mysql.com Subject: Re: query results group/summed by interval Hi Aveek, I think Ghulam just want to count calls for each intervals so the query should

Re: query results group/summed by interval

2010-07-30 Thread Nguyen Manh Cuong
mustafa...@gmail.com, mysql@lists.mysql.com Sent: Tuesday, July 27, 2010 5:54:13 PM Subject: RE: query results group/summed by interval try this ... select 5 * floor(seconds/5) as start, 5 * floor(seconds/5) + 5 as end, sum(calls) from calls group by 5 * floor(seconds/5); This should give you

RE: query results group/summed by interval

2010-07-27 Thread Aveek Misra
try this ... select 5 * floor(seconds/5) as start, 5 * floor(seconds/5) + 5 as end, sum(calls) from calls group by 5 * floor(seconds/5); This should give you an output of the type +---+--++ | start | end | sum(calls) | +---+--++ | 0 |5 |

Re: query executes very slow in a table with 2m records

2010-07-13 Thread mos
At 09:29 AM 7/13/2010, 李征 wrote: Hello, There are more than 2m records in the table -- fxrate. I create patitions, indexes, but it still takes me about 7 minutes to execute the following query SELECT COUNT(*) FROM fxrate WHERE MONTH(quoteDate) = 6 AND quoteHourMinSec BETWEEN 06:00:00 AND

RE: query executes very slow in a table with 2m records

2010-07-13 Thread Jerry Schwartz
You didn't include an EXPLAIN of your query (please use \G so that it is easy to read), but my guess is that MySQL decided to use a serial search rather than use an index. It is retrieved 1/4 of your records, and that's after applying the MONTH() test. The BETWEEN clause is the only place it

Re: query executes very slow in a table with 2m records

2010-07-13 Thread Rob Wultsch
On Tue, Jul 13, 2010 at 8:22 AM, mos mo...@fastmail.fm wrote: At 09:29 AM 7/13/2010, æ Žå¾  wrote: Hello, There are more than 2m records in the table -- fxrate. I create patitions, indexes, but it still takes me about 7 minutes to execute the following query SELECT COUNT(*) FROM fxrate

Re: query executes very slow in a table with 2m records

2010-07-13 Thread mos
At 10:36 AM 7/13/2010, Rob Wultsch wrote: On Tue, Jul 13, 2010 at 8:22 AM, mos mo...@fastmail.fm wrote: At 09:29 AM 7/13/2010, æ ŽÃ¥Â¾  wrote: Hello, There are more than 2m records in the table -- fxrate. I create patitions, indexes, but it still takes me about 7 minutes to execute the

RE: Query Help

2010-07-12 Thread Jay Blanchard
[snip] For the life of me I cannot remember how to make a query like this and what it is called. I know it is fairly basic though. Table 1 Product_id Product_Name Table 2 Category_id, Category_name Table 3 Product_id, Category_id Each product can have one or more categories. So I want a

Re: Query Help

2010-07-12 Thread Phillip Baker
Table 1 Product_id | Product_Name 1| Product A 2| Product B 3| Product C Table 2 Category_id | Category_Name 1 | Admin 2 | Marketing 3 | Support 4 | IT Table 3

Re: Query Help

2010-07-09 Thread Michael Satterwhite
I believe you're describing a crosstab query. This should help you put it together: http://rpbouman.blogspot.com/2005/10/creating-crosstabs-in-mysql.html ---Michael On Friday, July 09, 2010 07:37:41 pm Phillip Baker wrote: Hello All, For the life of me I cannot remember how to make a

Re: query help

2010-06-16 Thread Joerg Bruehe
Hi! Jay Blanchard wrote: [snip] I have a table similar to this: - |transactions | |ID |DATE |EMPLOYEE| |234 |2010-01-05| 345| |328 |2010-04-05| 344| |239 |2010-01-10| 344| Is there a way to query such a table to give the

Re: query help

2010-06-16 Thread Richard Reina
Thank you very much for all the insightful replies. I think I can get it to work with a join. Joerg Bruehe joerg.bru...@sun.com wrote: Hi! Jay Blanchard wrote: [snip] I have a table similar to this: - |transactions | |ID |DATE

RE: query help

2010-06-16 Thread Martin Gainty
Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. From: rich...@rushlogistics.com To: joerg.bru...@sun.com; mysql@lists.mysql.com Subject: Re: query help CC: jblanch

RE: query help

2010-06-15 Thread Gavin Towey
Hi Richard, This is a LEFT JOIN, but with only one table you may be wondering what to join. Typically you'll have to create a new table that contains all the dates in the range you want to check. Then you left join your transaction table, and all the rows from your dates table that don't

RE: query help

2010-06-15 Thread Jay Blanchard
[snip] I have a table similar to this: - |transactions | |ID |DATE |EMPLOYEE| |234 |2010-01-05| 345| |328 |2010-04-05| 344| |239 |2010-01-10| 344| Is there a way to query such a table to give the days of the year that employee 344 did

Re: Query Help!

2010-04-27 Thread Johan De Meersman
Hmm. You seem to have overlap, too. I suspect this would be easiest to do in code - the data you're looking for doesn't exist in the data you have, only the opposite of that data does. You could try populating a table with a full day, using the resolution you need (1 minute resolution means 1440

Re: Query Help!

2010-04-27 Thread Jo�o C�ndido de Souza Neto
Not tested, but I think it can help you or at least give you an ideia on how to do it. select EndDateTime + INTERVAL 1 SECOND as startLazy, (select StartDateTime - INTERVAL 1 SECOND from table t2 where t2.StartDateTime t1.EndDateTime limit 1) as endLazy from table t1 where (select

RE: query help

2010-02-09 Thread Gavin Towey
SELECT ID, check_no, amount FROM payables UNION SELECT ID, check_no, amount FROM paychecks; Regards, Gavin Towey -Original Message- From: Richard Reina [mailto:rich...@rushlogistics.com] Sent: Tuesday, February 09, 2010 9:23 AM To: mysql@lists.mysql.com Subject: query help I am trying

Re: query returning empty row

2010-01-17 Thread Dan Nelson
In the last episode (Jan 17), bharani kumar said: SELECT updateDate,cHospital,cHospital1,cHospital2 FROM med_patient WHERE cCurstatus!='completed' AND cMmrcashworker = '2' AND (cHospital = '1234' OR cHospital1 = '1234' OR cHospital2 ='1234') AND updateDate between '2010-01-01' and '2010-01-28'

Re: query returning empty row

2010-01-17 Thread bharani kumar
thanks for reply, problem fixed, On Mon, Jan 18, 2010 at 6:06 AM, Dan Nelson dnel...@allantgroup.com wrote: In the last episode (Jan 17), bharani kumar said: SELECT updateDate,cHospital,cHospital1,cHospital2 FROM med_patient WHERE cCurstatus!='completed' AND cMmrcashworker = '2' AND

RE: Query help

2009-12-13 Thread Jason Trebilcock
Depending on whether you just need to count or the transaction numbers, one of the following three should get you where you want/need to be: To identify the count for comp_id = 675: select count(distinct trans_no) from trans where comp_id = 675 and result = 'o'; To identify the transactions:

Re: Query help

2009-12-13 Thread Colin Streicher
On December 13, 2009 01:36:41 pm Richard Reina wrote: I was wondering if someone could lend a hand with the following query. I have table. SEARCHES |ID |trans_no|comp_id|result 13 | 455| 675| o 15 | 302| 675| o 16 | 455| 675| o 12 | 225| 629|

Re: Query help

2009-12-13 Thread DaWiz
SELECT count(distinct trans_no) from SEARCHES WHERE comp_id=675 and result='o'; - Original Message - From: Richard Reina rich...@rushlogistics.com To: mysql@lists.mysql.com Cc: rich...@rushlogistics.com Sent: Sunday, December 13, 2009 11:36 AM Subject: Query help I was wondering if

Re: Query!

2009-11-17 Thread Michael Dykman
I'm sorry, you are way off here in what this actually does. mysql_affected_rows is only going to tell you how many rows were affected by the execution of the last statement made on your current connection. It is not an interface to a magic genie maintaining watch over the state of your entire

Re: Query!

2009-11-17 Thread Peter Brawley
Gaurav, How can I detect from my code whether a table has been updated in the Database manually Have a look at Transaction Time Validity in http://www.osdbzine.net/issue6.pdf and http://www.osdbzine.net/issue7.pdf. PB - Michael Dykman wrote: I'm sorry, you are way off here in what

Re: Query :: Finding Date Difference

2009-09-27 Thread Colin Streicher
On September 26, 2009 05:10:23 am bharani kumar wrote: courier_id consignor_name consignor_address consignor_destination consignor_phone consignee_name consignee_address consignee_destination consignee_phone s_date s_date_mm s_date_ss r_date r_date_mm r_date_ss consignment_description

RE: query optimization question (my struggle against 'using temporary; using filesort')

2009-09-24 Thread Gavin Towey
Hi Ciaran, So I think there's a couple things going on: 1. The explain plan for your slow query looks wrong, such as mysql is confused. It's possible your index statistics are incorrect. Try ANALYZE TABLE on listings and addresses. I think a sure way to fix it is to add STRAIGHT_JOIN to

Re: query optimization question (my struggle against 'using temporary; using filesort')

2009-09-24 Thread Ciaran Lee
Hi Gavin,Thanks very much, I'll implement as many of your suggestions as possible. The varchar(255)'s are inexcusable and I feel suitably ashamed :) The queries were generated by ActiveRecord (an ORM library for Ruby), although even if I had written them myself they would probably not be much

Re: Query for rolling totals

2009-09-03 Thread Brent Baisley
You can do this using a variable. Set the variable starting value with a query: set @runningTotal := 0 Then add the calculation to your total: SELECT a. trans_id ,a.tran_date,b.cat_type,a.payee,a.amnt, @runningTotal := @runningTotal+a.amnt AS rollingTotal from transactions a join categories b on

Re: Query for rolling totals

2009-09-03 Thread John Daisley
Thank you Brent, much appreciated! On Thu, 2009-09-03 at 14:12 -0400, Brent Baisley wrote: You can do this using a variable. Set the variable starting value with a query: set @runningTotal := 0 Then add the calculation to your total: SELECT a. trans_id

Re: Query Question

2009-08-18 Thread Walter Heck - OlinData.com
Bill, if you use an order by clause in your query, the limit will pick the first 100K rows in that order. That way you can ensure that all rows will be processed in (wait for it...) order :) Cheers, Walter On Tue, Aug 18, 2009 at 18:44, Bill Arbuckle b...@arbucklellc.com wrote: I am in need

RE: Query Question

2009-08-18 Thread Gavin Towey
...@gmail.com] On Behalf Of Walter Heck - OlinData.com Sent: Tuesday, August 18, 2009 9:51 AM To: b...@arbucklellc.com Cc: mysql@lists.mysql.com Subject: Re: Query Question Bill, if you use an order by clause in your query, the limit will pick the first 100K rows in that order. That way you can

Re: Query Question

2009-08-18 Thread Martijn Tonies
To further emphasize this point: A table has no order by itself, That's not entirely true ;-) Records are stored in some kind of physical order, some DBMSses implement clustered keys, meaning that the records are stored ascending order on disk. However... and you should make no

Re: Query Question

2009-08-18 Thread Johnny Withers
It may be true that some DBMSs physically store rows in whatever order you speicfy; however, this is a MySQL list, and MySQL does not do this (InnoDB anyway). For example, take a table with 10,000,000 rows and run a simple select on it: Database changed mysql SELECT id FROM trans_item LIMIT 1\G

Re: Query Question

2009-08-18 Thread Martijn Tonies
It may be true that some DBMSs physically store rows in whatever order you speicfy; That's not what I said. however, this is a MySQL list, and MySQL does not do this (InnoDB anyway). For example, take a table with 10,000,000 rows and run a simple select on it: Database changed mysql

Re: query question...

2009-06-15 Thread Martijn Engler
It sounds to me like you want to join the two tables? http://dev.mysql.com/doc/refman/5.1/en/join.html On Mon, Jun 15, 2009 at 03:56, brucebedoug...@earthlink.net wrote: hi. i've got a situation, where i'm trying to figure out how to select an item from tblA that may/maynot be in tblB. if

Re: query question...

2009-06-15 Thread Shawn Green
Hi Bruce, bruce wrote: hi. i've got a situation, where i'm trying to figure out how to select an item from tblA that may/maynot be in tblB. if the item is only in tblA, i can easilty get a list of the items select * from tblA if the item is in tblA but not linked to tblB, i can get the

Re: Query from HPM book to limit rows scanned doesn't appear to work as described

2009-03-12 Thread David M. Karr
Baron Schwartz wrote: Hi! On Wed, Mar 11, 2009 at 8:20 PM, David M. Karr davidmichaelk...@gmail.com wrote: Using 5.0.67-0ubuntu6 on Ubuntu 8.10. I'm going through the High Performance MySQL book. I was reading section 4.4.1.8, titled MIN() and MAX(). The point of this is that MySQL

Re: Query from HPM book to limit rows scanned doesn't appear to work as described

2009-03-12 Thread Baron Schwartz
But EXPLAIN is only a prediction.  If you look at the changes in the Handler status variables, you'll see the second one reads fewer rows. Ok, I think I get it.  I first changed both of my queries to add sql_no_cache because without that, the Handler_read_rnd_next variable was zero in both

Re: Query from HPM book to limit rows scanned doesn't appear to work as described

2009-03-11 Thread Baron Schwartz
Hi! On Wed, Mar 11, 2009 at 8:20 PM, David M. Karr davidmichaelk...@gmail.com wrote: Using 5.0.67-0ubuntu6 on Ubuntu 8.10. I'm going through the High Performance MySQL book.  I was reading section 4.4.1.8, titled MIN() and MAX().  The point of this is that MySQL doesn't optimize MIN()/MAX()

Re: query and insert data on multiple tables

2009-02-13 Thread Baron Schwartz
Hi, On Fri, Feb 13, 2009 at 4:52 PM, PJ af.gour...@videotron.ca wrote: I am trying to create a php-mysql page to POST new records to several tables from one php page and I have to retrieve records from several (like 4 to 8) tables in one query. Being quite new to php mysql, I am wondering

RE: Query Help

2009-02-10 Thread Ben Wiechman
in question the information is returned. This produces too many results as some of those users have since migrated to a different access point. -Original Message- From: Andrew Wallo [mailto:theme...@microneil.com] Sent: Tuesday, February 10, 2009 12:05 PM To: Ben Wiechman Subject: Re: Query Help

RE: Query Help

2009-02-10 Thread Ben Wiechman
Alright to reply to myself I can return the information but have been unable to return the last row... instead it always returns the first row. Tried max, tried min, tried converting the datetime to a timestamp with the same results... mysql SELECT da_userinfo.UserName, da_userinfo.Name,

RE: Query Help

2009-02-10 Thread ddevaudreuil
Ben Wiechman b...@meltel.com wrote on 02/10/2009 01:30:14 PM: Thanks for the input! That is close to what I need, however not exactly. It will give me the last time a user logged into the host in question but I want to prune users who have since logged into a different host. Basically find

RE: Query Help

2009-02-10 Thread Ben Wiechman
: mysql@lists.mysql.com Subject: RE: Query Help Ben Wiechman b...@meltel.com wrote on 02/10/2009 01:30:14 PM: Thanks for the input! That is close to what I need, however not exactly. It will give me the last time a user logged into the host in question but I want to prune users who have since

Re: Query Optimization

2009-01-14 Thread Johnny Withers
The index hint is not in productoin code.. I was trying ot force it to use the index even when using the OR clause.. ment to take that out before I sent the email. The table structure is: CREATE TABLE `customer` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `ssn` varchar(32) DEFAULT NULL,

Re: Query Optimization

2009-01-13 Thread Ken Menzel
Try a union instead of an or condition. http://dev.mysql.com/doc/refman/5.0/en/union.html Johnny Withers wrote: I have the following tables: Customer: id,ssn Customer_Id: id,customer_id,id_num The customer table holds customers along with their SSN and the customer_id table holds

Re: Query Optimization

2009-01-13 Thread Andrew Garner
Do you have an index on id_num? What sort of explain output do you get when you don't use a query hint? Your USE INDEX hint may be causing MySQL to ignore a better strategy. If you have separate indexes on ssn and id_num, MySQL may be able to efficiently use an index merge optimization . See

Re: Query Optimization

2009-01-13 Thread Baron Schwartz
If you have separate indexes on ssn and id_num, MySQL may be able to efficiently use an index merge optimization . See http://dev.mysql.com/doc/refman/5.0/en/index-merge-optimization.html. This is only in 5.0+ - on older versions of MySQL you may find a union more efficient. And in newer

Re: Query Optimization

2009-01-13 Thread Andrew Garner
On Tue, Jan 13, 2009 at 7:07 PM, Baron Schwartz ba...@xaprb.com wrote: If you have separate indexes on ssn and id_num, MySQL may be able to efficiently use an index merge optimization . See http://dev.mysql.com/doc/refman/5.0/en/index-merge-optimization.html. This is only in 5.0+ - on older

Re: Query to Select records in the last 4 weeks

2008-12-04 Thread sangprabv
Hi, I have tried to use this query: SELECT count(smsc_id) as total, insertdate FROM momtbak WHERE insertdate BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL 4 WEEK) AND CURRENT_DATE() group by week(date_format(insertdate,'%Y-%m-%d'),3) to group records in the last 4 weeks by week. But the result

[SOLVED]Re: Query to Select records in the last 4 weeks

2008-12-04 Thread sangprabv
Hi, I finally found the solution SELECT count( smsc_id ) AS total, week( insertdate ) AS tanggal FROM momtbak WHERE insertdate BETWEEN DATE_SUB( CURRENT_DATE( ) , INTERVAL 4 WEEK ) AND CURRENT_DATE( ) GROUP BY week( insertdate ) Willy -- MySQL General Mailing List For list archives:

Re: Query to Select records in the last 4 weeks

2008-12-03 Thread Daevid Vincent
On Thu, 2008-12-04 at 08:27 +0700, sangprabv wrote: Hi, I get stuck to build a query to select records between curdate() and the last 4 weeks and groupped by week. I tested with: SELECT * FROM momtbak WHERE insertdate BETWEEN curdate( ) AND curdate( ) - INTERVAL 4 week It doesn't

Re: Query to Select records in the last 4 weeks

2008-12-03 Thread sangprabv
: sangprabv [EMAIL PROTECTED] Subject: Re: Query to Select records in the last 4 weeks Date: Wed, 03 Dec 2008 17:52:32 -0800 SELECT * FROM momtbak WHERE insertdate BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL 4 WEEK) AND CURRENT_DATE(); -- MySQL General Mailing List For list archives: http

Re: Query Cache questions

2008-09-17 Thread Bard Aase
On Wed, Sep 17, 2008 at 11:37 AM, Uwe Kiewel [EMAIL PROTECTED] wrote: Hi, I have two questions regarding the query cache: 1. What is the difference between query_cache_limit and query_cache_size? query_cache_limit is the maximum size of a single resultset in the cache. If your query results

Re: Query Cache questions

2008-09-17 Thread Uwe Kiewel
Bard Aase schrieb: On Wed, Sep 17, 2008 at 11:37 AM, Uwe Kiewel [EMAIL PROTECTED] wrote: Hi, I have two questions regarding the query cache: 1. What is the difference between query_cache_limit and query_cache_size? query_cache_limit is the maximum size of a single resultset in the cache.

Re: Query Cache questions

2008-09-17 Thread Bard Aase
On Wed, Sep 17, 2008 at 11:54 AM, Uwe Kiewel [EMAIL PROTECTED] wrote: Bard Aase schrieb: On Wed, Sep 17, 2008 at 11:37 AM, Uwe Kiewel [EMAIL PROTECTED] wrote: Hi, I have two questions regarding the query cache: 1. What is the difference between query_cache_limit and query_cache_size?

Re: Query Cache questions

2008-09-17 Thread Ananda Kumar
query_cache_limit is the maximum size of a single resultset in the cache. If your query results in a bigger resultset it will never get into the cache even if its room for it in the cache itself. Even if there is room why will it not fit into the cache. On 9/17/08, Bard Aase [EMAIL

Re: Query Cache questions

2008-09-17 Thread Bard Aase
On Wed, Sep 17, 2008 at 12:42 PM, Ananda Kumar [EMAIL PROTECTED] wrote: query_cache_limit is the maximum size of a single resultset in the cache. If your query results in a bigger resultset it will never get into the cache even if its room for it in the cache itself. Even if there is room

Re: Query Cache questions

2008-09-17 Thread Ananda Kumar
okie..got u On 9/17/08, Bard Aase [EMAIL PROTECTED] wrote: On Wed, Sep 17, 2008 at 12:42 PM, Ananda Kumar [EMAIL PROTECTED] wrote: query_cache_limit is the maximum size of a single resultset in the cache. If your query results in a bigger resultset it will never get into the cache even if

Re: Query cache contents

2008-09-16 Thread Parvesh Garg
http://rpbouman.blogspot.com/2008/07/inspect-query-cahce-using-mysql.html - parvesh On Wed, Sep 17, 2008 at 1:15 AM, Edson Noboru Yamada [EMAIL PROTECTED] wrote: Hey, Guys Is there a way to know what queries are in the query cache? thanks -- MySQL General Mailing List For list archives:

Re: Query optimization help

2008-08-12 Thread Brent Baisley
First, you might want to move the WHERE...t3.int_a = some integer condition into the join condition for t3. Your not using anything from t4, so I'm not sure why you have that table in your query. You can suggest or force mysql to use an index if it's using the wrong one:

Re: Query - One-to-Many question

2008-06-27 Thread Tina Matter
Peter, Yes, I know there are two rows in the course_subject table with a catalog_number of 520. One has a subject of 'ME' and the other has a subject of 'MSE'. What I want is ONLY the 'ME' row (if a row exists with a subject of 'ME').If an 'ME' subject row does not exist, then I want

<    1   2   3   4   5   6   7   8   9   10   >