Jump to content

SQLite select with multiple conditions


bandi94

Recommended Posts

I need to select a row , from a table but with 3 conditions.

Something like this

executeSQLQuery("SELECT value,day FROM Bank WHERE account_name=? , value=?,day=? ", getAccountName(acc),value_d,day_d) 

But how i tought it's not working like this. It is possible to make this ?? Or i need to select them only from the AccountName and after with loop ,sort them after the received data/values ?

EDIT: Ohh i just found out that i need to put "AND" , problem solved :D

Link to comment

haha yeah its AND. Without SQL knowledge it might be a entirely new world for you. This might be interesting to look at as an example;

    local id = executeSQLQuery("SELECT COUNT(ID) as 'id_' FROM player_vehicle") 
    insert = executeSQLQuery("INSERT INTO player_vehicle(ID, modelID,color1,color2,color3,color4,vehicleOwner, vehicleHealth, saveX, saveY, saveZ, saveRX, saveRY, saveRZ, spawned, fuel) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", id[1].id_, modelID, color_1, color_2, color_3,color_4, accName, "1000", 1464.8820, 748.1798, 11.5, 0, 0, 90, 1, 100 ) 

:)

Link to comment

Yah it's kinda new world for me :D

I hit another problem : I am saving bank deposit's , every deposit has a time in witch it can't be withdrawed.

Now when i deposit 2 time's (one after another) the same amount of money for same amount of day's , i will have a duplicated row :

( myname , 1000 , 5 )

( myname , 1000 , 5 )

this is fine bk i wanna keep every deposit separately, But when it come's the time of withdraw , i need to delete the row , but here come's the problem both of the row's will be deleted bk there are the same , but i wanna delete only one of them.

Is this possible or i need to insert one more column with the "deposit number (ID)" and use that for delete ?

Link to comment

Sorry for my late respond. The first thing you will have to learn while doing SQL is the Auto Increment type. The ID field is an AI field, it keeps counting whigher and higher with steps from 1 (default). All rows will become unique because of the AI. :) Easy to delete rows like that!

Link to comment
Sorry for my late respond. The first thing you will have to learn while doing SQL is the Auto Increment type. The ID field is an AI field, it keeps counting whigher and higher with steps from 1 (default). All rows will become unique because of the AI. :) Easy to delete rows like that!

pfuu. thx mate.

I made a whole function to keep ID's growing up one by one , when a simpel " ID INTEGER PRIMARY KEY AUTOINCREMENT," make's all the jobb :lol:

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...