Hi there...

I usually use mysql as a database engine, but sqlite has few unique
features that came handy in my last project, so... here I am :-)

Everything went well until yesterday, when I stumbled upon some
strange behavior... Example database:
+----+--------+------+-------------+
| ID | lineID | date | val         |
+----+--------+------+-------------+
|  1 |      1 |    1 | line1 test1 |
|  2 |      1 |    2 | line1 test2 |
|  3 |      2 |    3 | line2 test1 |
+----+--------+------+-------------+

What I'm trying to do is to get the whole rows with unique lineID's
and biggest date value... kinda like versioning.

Proper result should look like that:
+----+--------+------+-------------+
| ID | lineID | date | val         |
+----+--------+------+-------------+
|  2 |      1 |    2 | line1 test2 |
|  3 |      2 |    3 | line2 test1 |
+----+--------+------+-------------+
...but sqlite keeps returning just single row, no matter how many rows
should be returned.

The statement I use goes as follows:
SELECT * FROM (
  SELECT * FROM lines ORDER BY date DESC
  ) AS e
GROUP BY e.lineID

In mysql my code works as expected, but not here, which baffles me...

any help/suggestions/pointers are more than welcomed :-)

ps. I'm guilty of having v.2.8.17 of sqlite library, as it's the one
bundled with php version on server...

-- 
  Jo
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to