Jump to content
Sign in to follow this  
Digisoul

question about SQLite

Recommended Posts

Digisoul

Hello There,

I want to know that if i have 1000 records in SQLite DB, how can retrieve the data from the last Row ?

Thanks in Advance.


73 108 111 118 101 65 117 116 111 105 116

Share this post


Link to post
Share on other sites
JRowe

You can nest queries:

select * from Table  having rowid (select max(rowid) from Table)

Replace Table with your table.

Share this post


Link to post
Share on other sites
Digisoul

You can nest queries:

select * from Table  having rowid (select max(rowid) from Table)

Replace Table with your table.

Thank you very much JRowe. :idea:

73 108 111 118 101 65 117 116 111 105 116

Share this post


Link to post
Share on other sites
Digisoul

Its give me this error ?

!   SQLite.au3 Error
--> Function: _SQLite_Query
--> Query:    select id from Area having rowid (select max(rowid) from Area);
--> Error:    near "select": syntax error

73 108 111 118 101 65 117 116 111 105 116

Share this post


Link to post
Share on other sites
Yoriz

Try this

select * from Table where rowid in (select max(rowid) from Table)

Again replace Table with your table.


GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites
Digisoul

Try this

select * from Table where rowid in (select max(rowid) from Table)

Again replace Table with your table.

Not worked,

but this worked

"SELECT * FROM Table WHERE ROWID = ( SELECT MAX(ROWID) FROM Table) ;"

73 108 111 118 101 65 117 116 111 105 116

Share this post


Link to post
Share on other sites
Yoriz

select * from Table where rowid in (select max(rowid) from Table)

works just fine, both ways work.

#include <SQLite.au3>
#include <SQLite.dll.au3>
Local $aRow
_SQLite_Startup ()
ConsoleWrite("_SQLite_LibVersion=" &_SQLite_LibVersion() & @CRLF)
_SQLite_Open () ; open :memory: Database
_SQLite_Exec(-1,"CREATE TEMP TABLE settings (key,value);")
_SQLite_Exec(-1,"INSERT INTO settings (key,value) VALUES ('1','setting one');")
_SQLite_Exec(-1,"INSERT INTO settings (key,value) VALUES ('2','setting two');")
_SQLite_Exec(-1,"INSERT INTO settings (key,value) VALUES ('3','setting Three');")
_SQLite_Exec(-1,"INSERT INTO settings (key,value) VALUES ('4','setting Four');")
_SQLite_QuerySingleRow(-1,"SELECT value FROM settings where rowid in (select max(rowid) from settings);",$aRow) ; Select single row and single field !
ConsoleWrite("SELECT value FROM settings where rowid in (select max(rowid) from settings); returns = " & $aRow[0] & @CR)
_SQLite_QuerySingleRow(-1,"SELECT value FROM settings WHERE ROWID = ( SELECT MAX(ROWID) FROM settings);",$aRow) ; Select single row and single field !
ConsoleWrite("SELECT value FROM settings WHERE ROWID = ( SELECT MAX(ROWID) FROM settings); returns = " & $aRow[0] & @CR)
_SQLite_Close ()
_SQLite_Shutdown ()
;Console output _SQLite_LibVersion=3.6.22
;Console output SELECT value FROM settings where rowid in (select max(rowid) from settings); returns = setting Four
;Console output SELECT value FROM settings WHERE ROWID = ( SELECT MAX(ROWID) FROM settings); returns = setting Four

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×