Re: Help with an SQL query

2005-11-06 Thread Gobi
Rhino wrote: I'm glad the explanation helped. I figured that the solution alone wouldn't be very useful if it wasn't explained since it is not obvious to most people how correlated queries work :-) I really wasn't trying to center you out with my "rant" about MySQL version. It's been a long-run

Re: Help with an SQL query

2005-11-05 Thread Rhino
Rhino - Original Message - From: "Gobi" <[EMAIL PROTECTED]> To: Sent: Saturday, November 05, 2005 8:05 AM Subject: Re: Help with an SQL query > Rhino wrote: > > >I can't test this in MySQL- I'm using an older version of MySQL that doesn't &

Re: Help with an SQL query

2005-11-05 Thread Gobi
Rhino wrote: I can't test this in MySQL- I'm using an older version of MySQL that doesn't support subqueries - but it works in DB2 and it should do the trick for getting the current weight of each VBS_id value: select VBS_id, date, weight from VBS_table x where date = (select max(date) from VBS

Fw: Help with an SQL query

2005-11-04 Thread Rhino
Oops, I meant to post this on the list AND copy the person asking the question Rhino - Original Message - From: "Rhino" <[EMAIL PROTECTED]> To: "Gobi" <[EMAIL PROTECTED]> Sent: Friday, November 04, 2005 1:46 PM Subject: Re: Help with an SQL query &

Re: Help with an SQL query

2005-11-04 Thread Gobi
Figured out the query: select idx, vbs_id, date, weight from Weight, (select vbs_id as maxid, max(date) as maxdate from Weight group by vbs_id) as t where vbs_id = maxid and date = maxdate; It returns the proper weight and idx. -- MySQL General Mailing List For list archives: http://lists.mys

Re: Help with an SQL query

2005-11-04 Thread Johan Höök
Hi Gobi, the problem with your original query is that there is no guarantee that your max(date) and it's associated VBS_ID is picked, so what you have to ensure is that they get picked together, so I think your statement should be like this: SELECT VBS_ID, SUBSTRING( MAX( CONCAT( LPAD( Dat

Re: Help with an SQL query

2005-11-04 Thread Gobi
Johan Höök wrote: Hi Gobi, there was a similar posting in august. See: http://lists.mysql.com/mysql/187436 which I think describes what you want. I'll include a bit of it here as well -- This is out of the MySQL class and is called the Max-Concat trick. _

Re: Help with an SQL query

2005-11-04 Thread Gobi
Johan Höök wrote: Hi Gobi, there was a similar posting in august. See: http://lists.mysql.com/mysql/187436 which I think describes what you want. I'll include a bit of it here as well -- This is out of the MySQL class and is called the Max-Concat trick. _

Re: Help with an SQL query

2005-11-04 Thread Johan Höök
Hi Gobi, there was a similar posting in august. See: http://lists.mysql.com/mysql/187436 which I think describes what you want. I'll include a bit of it here as well -- This is out of the MySQL class and is called the Max-Concat trick. _

Re: Help with an SQL query

2005-11-04 Thread Gobi
Gobi wrote: Arno Coetzee wrote: Gobi wrote: Not sure if this is the right place to ask. I have a table, Weight, with the following test data: idx VBS_ID DateWeight 11110/3/200511.5 2119/5/2004 10 31110/7/200511.51 411

Re: Help with an SQL query

2005-11-04 Thread Gobi
Arno Coetzee wrote: Gobi wrote: Not sure if this is the right place to ask. I have a table, Weight, with the following test data: idx VBS_ID DateWeight 11110/3/200511.5 2119/5/2004 10 31110/7/200511.51 41110/8/2005

Re: Help with an SQL query

2005-11-04 Thread Arno Coetzee
Gobi wrote: Not sure if this is the right place to ask. I have a table, Weight, with the following test data: idx VBS_ID DateWeight 11110/3/200511.5 2119/5/2004 10 31110/7/200511.51 41110/8/200511.52 512

Help with an SQL query

2005-11-04 Thread Gobi
Not sure if this is the right place to ask. I have a table, Weight, with the following test data: idx VBS_ID DateWeight 11110/3/200511.5 2119/5/2004 10 31110/7/200511.51 41110/8/200511.52 51210/8/2005

Re: help with an SQL query

2005-02-22 Thread Ian Sales (DBA)
Michael Satterwhite wrote: - As it is, all I can suggest is to JOIN on all 90 tables - and hope MySQL can handle the query - and that you can type all of them without error. Note that if you use a UNION query as you suggest above, you will get the last login FOR EACH DAY - not the overall last logi

Re: help with an SQL query

2005-02-21 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, "J S" <[EMAIL PROTECTED]> writes: > and I need to check the last date each user logged on to the proxy in > the last 3 months. > In my database, there is a table for the users: mysql> desc user_table; > +---+--+--+-+-+--

Re: help with an SQL query

2005-02-21 Thread Michael Satterwhite
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 J S wrote: | | |> J S wrote: |> | Hi, |> | |> | I need a bit of help with a mySQL query. I have a list of users in a |> | text file called 'users': |> | |> | u655354 |> | u687994 |> | u696974 |> | u728141 |> | .. |> | .. |> | |> | and I need to check th

Re: help with an SQL query

2005-02-21 Thread J S
J S wrote: | Hi, | | I need a bit of help with a mySQL query. I have a list of users in a | text file called 'users': | | u655354 | u687994 | u696974 | u728141 | .. | .. | | and I need to check the last date each user logged on to the proxy in | the last 3 months. | | In my database, there is a ta

help with an SQL query

2005-02-21 Thread J S
Hi, I need a bit of help with a mySQL query. I have a list of users in a text file called 'users': u655354 u687994 u696974 u728141 .. .. and I need to check the last date each user logged on to the proxy in the last 3 months. In my database, there is a table for the users: mysql> desc user_tabl