The Arcive of vBulletin Modifications Site. |
|
Problems regarding PHP and MySQL! Details »»
|
|||||||||||||||||||||||||
Thanks for reading
![]() Im trying to intergrate my iste to my vb board and I have a problem. I'm writing an SQL query that looks like this: SELECT column1 FROM table WHERE column2 > (SELECT MAX(column2)-5 FROM table) The problem is that this isn't working because either Php or MySQL doesn't like my subquery. Does anyone know how I can write this to make it work? Can this Query be rewritten so I dont need the SubQuery? :disappointed: Show Your Support
|
|||||||||||||||||||||||||
| Comments |
|
#2
|
||||
|
||||
|
MySQL doesn't support sub queries, at least not yet.
Just use two queries. Code:
$max = $DB_site->query_first('SELECT MAX(column2) AS maxval FROM table');
$result = $DB_site->query('SELECT column1 FROM table WHERE column2 > '.($max['maxval']-5));
|
![]() |
|
|