PDA

View Full Version : Problems regarding PHP and MySQL!


Askepott
05-15-2002, 08:50 PM
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:

Admin
05-16-2002, 01:07 PM
MySQL doesn't support sub queries, at least not yet.

Just use two queries.
$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));