How to select rows from only the first N rows in a table?

2010-04-27 Thread Peng Yu
It seems that there is no direct support to limit 'select' to only the first N rows in a table. Could you let me know what the best way select rows from the first N rows in a table is? -- Regards, Peng -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To

Re: How to select rows from only the first N rows in a table?

2010-04-27 Thread Martijn Tonies
It seems that there is no direct support to limit 'select' to only the first N rows in a table. Could you let me know what the best way select rows from the first N rows in a table is? LIMIT usually works fine ;-) http://dev.mysql.com/doc/refman/5.0/en/select.html With regards, Martijn

RE: Join syntax problem

2010-04-27 Thread Steven Staples
As Tom Worster said, print($query); would show you what the query was trying to run. Without testing it, you also have some other whitespace issues between the hw.wildlife and FROM, and also, i m unsure of the asterix infront of the *images. On another note, when I do my JOINs, I tend to write

Query Help!

2010-04-27 Thread John Daisley
Hi All, I have a query I need to run but can't think how to get this working so I am hoping someone can advise. I have a table which logs start and end times of Scheduled jobs. It includes for simplicity a `DayID`, `StartDateTime` and `EndDateTime` column. Both `StartDateTime` and `EndDateTime`

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: How to select rows from only the first N rows in a table?

2010-04-27 Thread Dan Nelson
In the last episode (Apr 27), Martijn Tonies said: It seems that there is no direct support to limit 'select' to only the first N rows in a table. Could you let me know what the best way select rows from the first N rows in a table is? LIMIT usually works fine ;-)

Re: How to select rows from only the first N rows in a table?

2010-04-27 Thread Martijn Tonies
In the last episode (Apr 27), Martijn Tonies said: It seems that there is no direct support to limit 'select' to only the first N rows in a table. Could you let me know what the best way select rows from the first N rows in a table is? LIMIT usually works fine ;-)

order by numeric value

2010-04-27 Thread Keith Clark
I have the following statement: select chart_of_accounts.accountname as Account, concat('$',format(coalesce(sum(sales_journal_entries.debit),0),2)) as Debit, concat('$',format(coalesce(sum(sales_journal_entries.credit),0),2)) as Credit,

slow query on replication master and slave

2010-04-27 Thread Kandy Wong
Hi, Is it true that the performance of running a query on a live replication master and slave has to be much slower than running a query on a static server? I've tried to run the following query on a replication master and it takes 1 min 13.76 sec to finish. SELECT *, ABS(timeA-1266143632)

Re: order by numeric value

2010-04-27 Thread Carsten Pedersen
Keith Clark skrev: I have the following statement: select chart_of_accounts.accountname as Account, concat('$',format(coalesce(sum(sales_journal_entries.debit),0),2)) as Debit, concat('$',format(coalesce(sum(sales_journal_entries.credit),0),2)) as Credit,

Re: order by numeric value

2010-04-27 Thread Keith Clark
On Wed, 2010-04-28 at 00:18 +0200, Carsten Pedersen wrote: Keith Clark skrev: I have the following statement: select chart_of_accounts.accountname as Account, concat('$',format(coalesce(sum(sales_journal_entries.debit),0),2)) as Debit,

Re: order by numeric value

2010-04-27 Thread DaWiz
Try order by CAST(Balance as decimal(8,2)) asc; Cast will work in the order by. Glenn Vaughn - Original Message - From: Keith Clark keithcl...@k-wbookworm.com To: mysql@lists.mysql.com Sent: Tuesday, April 27, 2010 3:52 PM Subject: order by numeric value I have the following

RE: order by numeric value

2010-04-27 Thread Gavin Towey
That won't work on a value like $1.00 select CAST('$1.00' as decimal(8,2)); +---+ | CAST('$1.00' as decimal(8,2)) | +---+ | 0.00 | +---+ 1 row in set, 1 warning (0.00 sec)

RE: order by numeric value

2010-04-27 Thread Keith Clark
But I'd prefer not to see the extra sorting field. Keith On Tue, 2010-04-27 at 15:49 -0700, Gavin Towey wrote: That won't work on a value like $1.00 select CAST('$1.00' as decimal(8,2)); +---+ | CAST('$1.00' as decimal(8,2)) | +---+

Re: order by numeric value

2010-04-27 Thread Jesper Wisborg Krogh
On Wed, 28 Apr 2010 08:53:57 Keith Clark wrote: But I'd prefer not to see the extra sorting field. You don't need to select a field in order to be able to order by it. So select chart_of_accounts.accountname as Account, concat('$',format(coalesce(sum(sales_journal_entries.debit),0),2)) as

Re: order by numeric value

2010-04-27 Thread Keith Clark
On Wed, 2010-04-28 at 08:57 +1000, Jesper Wisborg Krogh wrote: On Wed, 28 Apr 2010 08:53:57 Keith Clark wrote: But I'd prefer not to see the extra sorting field. You don't need to select a field in order to be able to order by it. So select chart_of_accounts.accountname as Account,

Re: sql to duplicate records with modified value

2010-04-27 Thread Voytek Eymont
thanks, Ray, that worked well (btw, you have a typo, 'Independant' instead of 'Independent') btw2, I have a pdf with some 15,000 names that I would like to display with a search function, I email you later, maybe you can help me with that -- Voytek quote who=Ray Cauchi Hi Voytek You