Jump to content
php.lv forumi

Recommended Posts

Posted

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  )

Posted

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.

×
×
  • Create New...