Zandis Murāns Posted March 12, 2008 Report Posted March 12, 2008 Kā lai dabū tabulas pirmo un pēdējo rindu bez php?
andrisp Posted March 12, 2008 Report Posted March 12, 2008 Pēc kā skatoties pirmo un pēdējo ? Pēc ID ? SELECT * FROM table ORDER BY id ASC LIMIT 1 SELECT * FROM table ORDER BY id DESC LIMIT 1 Ja baigi gribas, lai vienā kverijā: (SELECT * FROM table ORDER BY id ASC LIMIT 1 ) UNION (SELECT * FROM table ORDER BY id DESC LIMIT 1 )
Aleksejs Posted March 12, 2008 Report Posted March 12, 2008 vai arī SELECT * FROM tabula WHERE lauks IN (SELECT MAX(lauks) FROM tabula) OR lauks IN (SELECT MIN(lauks) FROM tabula) bet tas negarantē tieši divu rezultātu atgriešanu.
Recommended Posts