Answer the question
In order to leave comments, you need to log in
How to write an INSERT-SELECT query?
In general, it is necessary to add a new value to the old balance indicator.
Query where is current balance running:
INSERT INTO `test_db_vytrat` (`balans`) select balans+1000 from test_db_vytrat where user_id = 1 ORDER BY `id` DESC LIMIT 0 , 1;
INSERT INTO `test_db_vytrat` (`id`, `user_id`, `data`, `cat`, `oper`, `suma_oper`, `balans`, `note`) VALUES (NULL, '$_POST[uid]', '$_POST[data]', '$_POST[category]', '$_POST[type]', '$_POST[suma]', select balans+1000 from test_db_vytrat where user_id = 1 ORDER BY `id` DESC LIMIT 0 , 1, '$_POST[note]');
Answer the question
In order to leave comments, you need to log in
INSERT INTO `test_db_vytrat` (`id`, `user_id`, `data`, `cat`, `oper`, `suma_oper`, `balans`, `note`)
SELECT NULL as id, '{$_POST[uid]}' as user_id, '{$_POST[data]}' as data, ..., balans+1000 as balans, '{$_POST[note]}' as note from test_db_vytrat where user_id = 1 ORDER BY `id` DESC LIMIT 0 , 1;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question