>>>> 2012/09/06 08:50 -0400, Mark Haney >>>>
>SELECT vLight.* FROM
>(SELECT lights.*, machine.mach_name from lights
>JOIN machine ON lights.mach_id = machine.mach_id
>ORDER BY date DESC) as vLight
>GROUP BY mach_id
<<<<<<<<
How about

SELECT lights.*, machine.mach_name
FROM lights JOIN machine USING (mach_id)
/* ORDER BY date DESC */
GROUP BY mach_id

? With USING the fields "mach_id" from "lights" and "machine" become one 
unambiguous field "mach_id".

Does "mach_id" really occur more times in "lights" or "machine"? If only once 
in both tables, GROUP BY at most orders it. It is not clear that ORDER BY does 
anything with GROUP BY outside it, unless "mach_id" is unique in both tables--I 
have found that GROUP BY not always orders the output, when everything is 
unique.

And yes, MySQL balks at saving a view with a query for a table. One has to make 
them separate views. 


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql

Reply via email to