bokeh
02-22-2007, 12:13 PM
SELECT
min(`$IdColumn`) AS `first`,
max(`$IdColumn`) AS `last`
FROM `$tablename`
That query works ok as does this one:SELECT
max(`$IdColumn`) AS `prev` WHERE `$IdColumn` < '$id'
FROM `$tablename`but I am trying to make a combined query something like this:SELECT
max(`$IdColumn`) AS `prev` WHERE `$IdColumn` < '$id',
min(`$IdColumn`) AS `next` WHERE `$IdColumn` > '$id',
min(`$IdColumn`) AS `first`,
max(`$IdColumn`) AS `last`
FROM `$tablename`I'm not sure of the correct syntax to use and want to avoid doing multiple queries.
min(`$IdColumn`) AS `first`,
max(`$IdColumn`) AS `last`
FROM `$tablename`
That query works ok as does this one:SELECT
max(`$IdColumn`) AS `prev` WHERE `$IdColumn` < '$id'
FROM `$tablename`but I am trying to make a combined query something like this:SELECT
max(`$IdColumn`) AS `prev` WHERE `$IdColumn` < '$id',
min(`$IdColumn`) AS `next` WHERE `$IdColumn` > '$id',
min(`$IdColumn`) AS `first`,
max(`$IdColumn`) AS `last`
FROM `$tablename`I'm not sure of the correct syntax to use and want to avoid doing multiple queries.