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:

Query to Select records in the last 4 weeks

2008-12-03 Thread sangprabv
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 work. Please help, TIA. Willy Every why hath a wherefore

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

Query question: select * from table where id in (1,2,3) order by date uses FILESORT

2006-06-20 Thread Peter Van Dijck
Hi all, this is a problem I'm running into: A table has like 400,000 rows, with a primary key index id. I use this query: SELECT * FROM table WHERE id IN (58, 25, 75, ...) ORDER BY post_date DESC LIMIT 0, 40 The problem is, it uses the index id and then a FILESORT. Questions: 1) Am I correct

Re: Query question: select * from table where id in (1,2,3) order by date uses FILESORT

2006-06-20 Thread Brent Baisley
what mysql is going to do. - Original Message - From: Peter Van Dijck [EMAIL PROTECTED] To: mysql@lists.mysql.com Sent: Tuesday, June 20, 2006 3:08 AM Subject: Query question: select * from table where id in (1,2,3) order by date uses FILESORT Hi all, this is a problem I'm running

Re: Query question: select * from table where id in (1,2,3) order by date uses FILESORT

2006-06-20 Thread Dan Buettner
, 2006 3:08 AM Subject: Query question: select * from table where id in (1,2,3) order by date uses FILESORT Hi all, this is a problem I'm running into: A table has like 400,000 rows, with a primary key index id. I use this query: SELECT * FROM table WHERE id IN (58, 25, 75, ...) ORDER

Query to select...

2005-05-24 Thread Dan Bolser
Hello, I have data like this PK GRP_COL 1 A 2 A 3 A 4 B 5 B 6 B 7 C 8 C 9 C And I want to write a query to select data like this... PK FK GRP_COL 1 1 A 2 1 A 3 1 A 4 4 B 5

Re: Query to select...

2005-05-24 Thread mfatene
Hi, try for axample, select PK, ord(GRP_COL),COL from your_table; Mathias Selon Dan Bolser [EMAIL PROTECTED]: Hello, I have data like this PKGRP_COL 1 A 2 A 3 A 4 B 5 B 6 B 7 C 8 C 9 C And I want to write a query to select data like

Re: Query to select...

2005-05-24 Thread SGreen
Dan Bolser [EMAIL PROTECTED] wrote on 05/24/2005 06:08:32 AM: Hello, I have data like this PK GRP_COL 1 A 2 A 3 A 4 B 5 B 6 B 7 C 8 C 9 C And I want to write a query to select data like this... PK FK GRP_COL 1 1 A 2 1 A 3 1 A 4 4

Re: Query to select...

2005-05-24 Thread Michael Stassen
GRP_COL 1 A 2 A 3 A 4 B 5 B 6 B 7 C 8 C 9 C And I want to write a query to select data like this... PK FK GRP_COL 1 1 A 2 1 A 3 1 A 4 4 B 5 4 B 6 4 B 7 7

Re: Query to select...

2005-05-24 Thread Dan Bolser
| 1 | 12e8 | 1 | | 12e8| 1 | 12e8 | 2 | ... Cheers, Mathias Selon Dan Bolser [EMAIL PROTECTED]: Hello, I have data like this PK GRP_COL 1A 2A 3A 4B 5B 6B 7C 8C 9C And I want to write a query to select data like

Re: Query to select...

2005-05-24 Thread Michael Stassen
[EMAIL PROTECTED] wrote: Dan Bolser [EMAIL PROTECTED] wrote on 05/24/2005 06:08:32 AM: Hello, I have data like this PK GRP_COL 1 A 2 A 3 A 4 B 5 B 6 B 7 C 8 C 9 C And I want to write a query to select data like this... PK FK GRP_COL 1 1 A 2 1 A 3 1 A 4

Re: Query to select...

2005-05-24 Thread mfatene
(GRP_COL),COL from your_table; Mathias Selon Dan Bolser [EMAIL PROTECTED]: Hello, I have data like this PK GRP_COL 1 A 2 A 3 A 4 B 5 B 6 B 7 C 8 C 9 C And I want to write a query to select data like this... PK FK GRP_COL 1 1 A 2 1

Re: Query to select...

2005-05-24 Thread SGreen
a query to select data like this... PK FK GRP_COL 1 1 A 2 1 A 3 1 A 4 4 B 5 4 B 6 4 B 7 7 C 8 7 C 9 7 C Where FK is a random (or otherwise) member of PK from within the appropriate group given by GRP_COL. FK recreates the grouping from

Re: Query to select...

2005-05-24 Thread Dan Bolser
blip I agree, especially with the additional information the OP provided about his REAL table structure. A separate groups table makes better sense. Let this be an object lesson to others looking for assistance: If you want timely and useful assistance, provide real and complete information

Re: Query to select...

2005-05-24 Thread Dan Bolser
On Tue, 24 May 2005 [EMAIL PROTECTED] wrote: Selon Dan Bolser [EMAIL PROTECTED]: Hello, I have data like this PK GRP_COL 1A 2A 3A 4B 5B 6B 7C 8C 9C And I want to write a query to select data like this... PK FK GRP_COL 11

query to select only numeric portion of string

2004-07-25 Thread Wesley Furgiuele
Using MySQL 4.0.20, I need to extract just the numeric portion of a string in a field and move it to another field in the same table, but I'd only like to do this if the value actually starts with a number. So, what I'm looking to accomplish is: UPDATE table SET field2 = VOODOO( field1 ) The

Re: How to write query to select the Max(version) for each unique file_name record?

2003-07-21 Thread Michael Satterwhite
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Sunday 20 July 2003 22:59, Tanamon wrote: ++---+--+ | id | file_name | max(version) | ++---+--+ | 6 | ffour |2 | | 1 | fone |3 | | 5 | fthree|

How to write query to select the Max(version) for each unique file_name record?

2003-07-20 Thread Tanamon
Hello All, I am a MySQL newbie trying to write a query that selects file_name records possessing the highest numbered version for that unique file_name. I show sample data and two trial queries below. Logically I want to use max(version) as a constraint in a Where Clause. However, the max()

RE: sql query using select and row functions

2003-01-29 Thread Christopher Lyon
Thank you all for your help. I think that is all I need to do is select it by row. -Original Message- From: R. Hannes Niedner [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 28, 2003 2:02 PM To: Christopher Lyon; MySQL Mailinglist Subject: Re: sql query using select and row

sql query using select and row functions

2003-01-28 Thread Christopher Lyon
I am trying to do an sql query and am trying to select the last x rows from the database. I see the limit function but that seems like that is from the first row down. I want to start from the last row to the first row. So, selecting the last 5 rows for instance? Can this be done?

RE: sql query using select and row functions

2003-01-28 Thread Mike Hillyer
Why not just reverse your order by clause and use Limit 5? Mike Hillyer -Original Message- From: Christopher Lyon [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 28, 2003 9:26 AM To: [EMAIL PROTECTED] Subject: sql query using select and row functions I am trying to do an sql query

Re: sql query using select and row functions

2003-01-28 Thread R. Hannes Niedner
On 1/28/03 8:26 AM, Christopher Lyon [EMAIL PROTECTED] wrote: I am trying to do an sql query and am trying to select the last x rows from the database. I see the limit function but that seems like that is from the first row down. I want to start from the last row to the first row. So,

RE: sql query using select and row functions

2003-01-28 Thread Fernando Grijalba
Try ordering the records backwards, e.g ORDER BY id DESC and then limit 0, 5 HTH JFernando * sql * -Original Message- From: Christopher Lyon [mailto:[EMAIL PROTECTED]] Sent: January 28, 2003 11:26 To: [EMAIL PROTECTED] Subject: sql query using select and row functions I am trying

RE: sql query using select and row functions

2003-01-28 Thread Victor Pendleton
AM To: [EMAIL PROTECTED] Subject: sql query using select and row functions I am trying to do an sql query and am trying to select the last x rows from the database. I see the limit function but that seems like that is from the first row down. I want to start from the last row to the first row

RE: sql query using select and row functions

2003-01-28 Thread Christopher Lyon
I would think they would be the same no? It turns out in the database that they are the same. -Original Message- From: Victor Pendleton [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 28, 2003 12:23 PM To: Christopher Lyon; [EMAIL PROTECTED] Subject: RE: sql query using select

RE: sql query using select and row functions

2003-01-28 Thread Victor Pendleton
Pendleton; [EMAIL PROTECTED] Subject: RE: sql query using select and row functions I would think they would be the same no? It turns out in the database that they are the same. -Original Message- From: Victor Pendleton [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 28, 2003 12:23

Re: sql query using select and row functions

2003-01-28 Thread R. Hannes Niedner
. Hannes Niedner [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 28, 2003 11:50 AM To: Christopher Lyon; MySQL Mailinglist Subject: Re: sql query using select and row functions On 1/28/03 8:26 AM, Christopher Lyon [EMAIL PROTECTED] wrote: I am trying to do an sql query and am trying

Re: sql query using select and row functions

2003-01-28 Thread Adolfo Bello
On Tue, 2003-01-28 at 12:26, Christopher Lyon wrote: I am trying to do an sql query and am trying to select the last x rows from the database. I see the limit function but that seems like that is from the first row down. I want to start from the last row to the first row. So, selecting the