Jump to content

Recommended Posts

Hi

 

I'm trying to select borderbg, bg1, bg2 in my query WHERE cupID = highest value-1 if that make sense?

 

$style = mysql_query("SELECT borderbg, bg1, bg2 FROM ".PREFIX."cup_baum WHERE cupID=''");

 

e.g. table:

 

cupID: (auto_increment)

 

78

77

76

75

...

 

$style selects borderbg, bg1, bg2 WHERE cupID=77 because it has the highest value-1 in the table. (or second highest)

 

Any help will be great

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/208864-where-clause/
Share on other sites

You can't use MAX() like that, and even if you could if you deleted a record it could potentially break the code.

 

Instead you can try:

 

$style = mysql_query("SELECT borderbg, bg1, bg2 FROM ".PREFIX."cup_baum ORDER BY cupID DESC LIMIT 1,1");

Link to comment
https://forums.phpfreaks.com/topic/208864-where-clause/#findComment-1091112
Share on other sites

Are you sure? I was curious as to which method would be faster so I was going to do a test, and I received an "invalid use of group function" error. I also recall encountering a similar problem when attempting to use MAX() in a similar situation a while ago.

Link to comment
https://forums.phpfreaks.com/topic/208864-where-clause/#findComment-1091123
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.