What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Why wont this mySQL query wont work?

Why wont this mySQL query wont work?
Author: Message:
Mike
Elite Member
*****

Avatar
Meet the Spam Family!

Posts: 2795
Reputation: 48
32 / Male / Flag
Joined: Mar 2003
Status: Online
O.P. Sad  Why wont this mySQL query wont work?
code:
SELECT MAX(ID), `artist`, `title` FROM `historylist`

It says:
quote:
Originally posted by mySQL Error
#1140 - Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause

I tried doing something like that:
code:
SELECT MAX(ID), `artist`, `title` FROM `historylist` GROUP BY `ID`
but it didnt just show that Max(ID), it also showed other IDs, with wrong artists and titles...

Anyone help please? :)

Thanks.
YouTube closed-captions ripper (also allows you to download videos!)
09-14-2005 07:08 PM
Profile E-Mail PM Web Find Quote Report
wj
Former Admin
*****

Avatar
I aim to misbehave.

Posts: 2224
Reputation: 52
39 / – / Flag
Joined: Mar 2002
RE: Why wont this mySQL query wont work?
SELECT `ID`, `artist`, `title` FROM `historylist` WHERE  ID IN (SELECT max(ID) FROM historylist)

That should do ya.
"A towel is about the most massively useful
thing an interstellar hitchhiker can have."
09-14-2005 08:24 PM
Profile PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: Why wont this mySQL query wont work?
SELECT `ID`, `artist`, `title`
FROM `historylist`
WHERE `ID` = SELECT MAX(ID) FROM `historylist`;

Embedded SELECTs rock!

Edit:
quote:
Originally posted by wj
SELECT `ID`, `artist`, `title` FROM `historylist` WHERE  ID IN (SELECT max(ID) FROM `historylist`);
should also work.

This post was edited on 09-14-2005 at 08:28 PM by RaceProUK.
[Image: spartaafk.png]
09-14-2005 08:26 PM
Profile PM Web Find Quote Report
Mike
Elite Member
*****

Avatar
Meet the Spam Family!

Posts: 2795
Reputation: 48
32 / Male / Flag
Joined: Mar 2003
Status: Online
O.P. RE: Why wont this mySQL query wont work?
Thanks for your help [Image: msn_happy.gif]

optiz0r from IRC helped me too.

He gave me this code:
code:
SELECT  `artist` ,  `title`
FROM  `historylist`
ORDER  BY  `ID`  DESC
LIMIT 1
which also works [Image: msn_happy.gif]

YouTube closed-captions ripper (also allows you to download videos!)
09-15-2005 09:18 AM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On