[SQLite] Deleted rows count
#1

Is there in sqlite something? i know i can use
pawn Код:
SELECT * FROM table WHERE nick = '%s'
and then num_rows but im asking about one query
pawn Код:
DELETE FROM table WHERE nick = '%s'
and next how many rows are deteled ?
Reply
#2

You could use
pawn Код:
SELECT changes()
to return the recent changes in your database

For example this is your database structure.
pawn Код:
-> table_name
- row 1 ->
- row 2 ->
- row 3 ->
- row 4 ->
- row 5 ->
- row 6 ->

All rows with the name of 'Patrick'
then you run a query
pawn Код:
DELETE FROM table_name WHERE username = 'Patrick'
then you run the changes() function, which will return the number of rows that has been deleted.
Reply
#3

Sure but i need another query as my first example, im asking about
pawn Код:
DELETE FROM table WHERE nick = 'Patrick'
new rows = db_num_rows();
or something like this
Reply
#4

Quote:
Originally Posted by Jefff
Посмотреть сообщение
Sure but i need another query as my first example, im asking about
pawn Код:
DELETE FROM table WHERE nick = 'Patrick'
new rows = db_num_rows();
or something like this
You could execute 2 statements in 1 query by using semicolon ' ; ' to separate them.

pawn Код:
new
    DBResult:res;

res = db_query(dbHandle, "DELETE FROM table_name where nick = 'Patrick'; SELECT changes()");

printf("deleted rows = %i", db_get_field_int(res)); //this will print the deleted rows, or the recent changes.
db_free_result(res);
Reply
#5

Ok nice xd solved!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)