SQLITE update, limit, case -


enter image description herei want implement parking lot application there garage 5 or more parking lots when driver parks car next free slot in garage should assigned him.

so have table garage 5 or more slots have problem when update update garage set free = 0, set car = 1 (car_id) free slots update how can limit update first free row?

can me

thanks in advance (false) have garage table levels , slots in each level when park car want update free slots

table garage

you'll need specify record(s) want update, or database update all of them. if you're looking update 1 record specifically, might want reference primary key where clause.

if haven't assigned primary key table, you use sqlite's rowid column. this:

select rowid garage free = 1; 

then, supposing identify spot 5 free car 42:

update garage set free = 0, car = 42 rowid = 5; 

if prefer, can combine 2 steps single query:

update garage set free=0, car=42 rowid in (select rowid garage free=1 limit 1); 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -