How to get last record for each product

2010-07-20 Thread Tompkins Neil
Hi, I have a list of product orders in a table with the following structure : OrderID ProductID OrderDate OrderCost What query would I need to get the last order for each productID ? Cheers, Neil

RE: How to get last record for each product

2010-07-20 Thread Jay Blanchard
[snip] I have a list of product orders in a table with the following structure : OrderID ProductID OrderDate OrderCost What query would I need to get the last order for each productID ? [/snip] MAX(OrderDate) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To

Re: How to get last record for each product

2010-07-20 Thread Aveek Misra
SELECT ProductID, MAX(OrderDate) FROM table GROUP BY ProductID; or if you want all the columns SELECT * FROM table a, (SELECT ProductID, MAX(OrderDate) as MaxDate FROM table GROUP BY ProductID) as b WHERE a.ProductID = b.ProductID AND a.OrderDate = b.MaxDate; Tompkins Neil wrote: Hi, I

sorting numbers as spelled

2010-07-20 Thread Ramsey, Robert L
Say I have the following data: +---+ | title | +---+ | ...And justice

Re: mysql-workbench-gpl-5.2.25-1el6.x86_64.rpm depends on a lot of stuff I do not have

2010-07-20 Thread Joerg Bruehe
Hi Mike, all! Mike Spreitzer schrieb: Today I downloaded MySQL-server-community, MySQL-client-community, MySQL-shared-community, and mysql-workbench-gpl to install on an RHEL5/x86_64 machine. The first three installed just fine. The fourth failed due to a large pile of missing

Re: sorting numbers as spelled

2010-07-20 Thread mos
Robert, The titles should be sorted as they are stored. The 12 should come before the other titles, just as they do with other online movie databases. See http://www.imdb.com/find?s=allq=angry The only problem would be of course if someone searches on Twelve, it should also return movies

Re: Decimal points

2010-07-20 Thread Chris W
Mark Goodge wrote: This is the sort of thing that is far better handled in the application layer, rather than the database layer. PHP, for example, even has a built-in function which will do this: setype($value,float); I agree about using the application layer, but I like to use type

newb problem

2010-07-20 Thread dennis skinner
Hello I am a new mysql user. Can anyone tell me why this does not create a table? ?php(the spaces before the question mark are not in the code) $dbuser=smeduser; $dbpassword=x; $dbname=smed; mysql_connect(localhost, $dbuser, $dbpassword); mysql_select_db($dbname) or

Re: newb problem

2010-07-20 Thread Wm Mussatto
On Tue, July 20, 2010 09:28, dennis skinner wrote: Hello I am a new mysql user. Can anyone tell me why this does not create a table? ?php(the spaces before the question mark are not in the code) $dbuser=smeduser; $dbpassword=x; $dbname=smed;

Re: newb problem

2010-07-20 Thread Chris W
'unsigned' is part of your data type which must be before the 'not null' Your closing ) needs to be at the very end. There is no reason t have the unique id since the primary key is unique. First you need the column name 'patid' then the data type 'INT UNSIGNED' then the other column

Re: [MySQL] Re: Decimal points

2010-07-20 Thread Ashley M. Kirchner
On 7/20/2010 10:07 AM, Chris W wrote: I try to avoid asking why but in this case I have to. I can't imagine wanting to have a list of numbers displayed and not have them all aligned right with the sane number of digits after the decimal point. So why would you even want to do this is?

RE: [MySQL] Re: Decimal points

2010-07-20 Thread Steven Staples
Just out of curiosity, why not do it in the application layer? Or maybe, you can try: SELECT BINARY 1+1.2; = 2.2 SELECT BINARY 1+1.0; = 2 SELECT CAST(1+1.2 AS UNSIGNED); = 2 SELECT CAST(1+1.6 AS UNSIGNED); = 3 (so I guess rounding happens here) And then I guess ultimately, you could also use