LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] MySQL question

[ILUG] MySQL question

Niall O Broin niall at linux.ie
Sat Sep 1 15:33:06 IST 2001


Given two tables


mysql> describe Customers;
+--------------+-------------+------+-----+-----------+----------------+
| Field        | Type        | Null | Key | Default   | Extra          |
+--------------+-------------+------+-----+-----------+----------------+
| Username     | varchar(32) |      | UNI |           |                |
| Password     | varchar(32) | YES  |     | NULL      |                |
| ID           | smallint(6) |      | PRI | NULL      | auto_increment |
| Name         | varchar(50) |      |     |           |                |
+--------------+-------------+------+-----+-----------+----------------+
9 rows in set (0.00 sec)
 
 mysql> describe Deliveries;
 +-------------+---------------+------+-----+------------+-------+
 | Field       | Type          | Null | Key | Default    | Extra |
 +-------------+---------------+------+-----+------------+-------+
 | Customer_ID | smallint(6)   |      | PRI | 0          |       |
 | Picture_ID  | int(11)       |      | PRI | 0          |       |
 | Date        | date          |      | PRI | 0000-00-00 |       |
 | When        | timestamp(14) | YES  |     | NULL       |       |
 +-------------+---------------+------+-----+------------+-------+
 4 rows in set (0.00 sec)                 

How do I get a listing of Customers with the date of each customer's latest
delivery, ordered by the date ? I tried 

select Name, max(Date) as Max from Customers, Deliveries order by Max; 

but that tells me that 

Mixing of GROUP columns (MIN(),MAX(),COUNT()...) with no GROUP columns is
illegal if there is no GROUP BY clause

so I tried various combinations of GROUP BY with no great success. Can I do I
do this and if so, how (and given that it's MySQL, I hope the answer doesn't
involve subselects :-( )



Regards,



Niall




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell