PDA

View Full Version : SQLite - Selecting And Retrieving Data With Specifications


DrakeX
22/05/2014, 03:12 AM
Is there a way to select or sort data from a query and ensure it's greater then a specified integer? Such as...

new DBResult:result;
result = db_query(database, "SELECT `VALUE` FROM `TABLE` ORDER BY (`VALUE` * 1) WHERE `VALUE` > `0`");
db_free_result(result);

I'm trying to retrieve data, but I'd like it to only retrieve entries from the database that are greater then 0. Thanks.

Mark_Weston
22/05/2014, 03:23 AM
You're doing it correctly, are you getting any errors or anything?

DrakeX
22/05/2014, 03:34 AM
You're doing it correctly, are you getting any errors or anything?

Oh, I am? :| What I had wrote was just an example of something I was looking for, I honestly didn't know such a thing could be queried. Thanks.

Edit: Using this include (http://forum.sa-mp.com/showthread.php?t=468260), I'm receiving this:

[22:26:25] (db_query) Error: near "WHERE": syntax error

Konstantinos
22/05/2014, 09:58 AM
"SELECT VALUE FROM TABLE WHERE VALUE > 0 ORDER BY VALUE ASC"

Mark_Weston
22/05/2014, 01:27 PM
"SELECT VALUE FROM TABLE WHERE VALUE > 0 ORDER BY VALUE ASC"


Oh yeah shit.

Here if you want to ORDER BY.

http://www.w3schools.com/sql/sql_orderby.asp