So i have the following table
but when i run the following command:
"INSERT INTO default_db.loader_messages (confirmation_secure_radio_button_message) VALUES ('$confirmmessagevalue1')";
it adds a new row, but empties the loader_message1 column as you can see above.
please tell me how do i keep the current data in the loader_message1 column as well as add a new row ?
If you can change from an insert..values to insert..select then you could
drop table if exists t;
create table t (id int auto_increment primary key,col1 varchar(10),col2 varchar(10));
insert into t (col1) values ('col1');
insert into t (col1,col2)
select col1,'aaa'
from t where id = (select max(id) from t)
;
insert into t (col1) values ('xxx');
insert into t (col1,col2)
select col1,'bbb'
from t where id = (select max(id) from t)
;
select * from t;
+----+------+------+
| id | col1 | col2 |
+----+------+------+
| 1 | col1 | NULL |
| 2 | col1 | aaa |
| 3 | xxx | NULL |
| 4 | xxx | bbb |
+----+------+------+
4 rows in set (0.02 sec)
if this is not a possibility for you then consider capturing in your front end before inserting or inserting in a procedure and fill down after the insert using an update.
I mentioned that it is a poor design to replicate column value to multiple rows.
Still...you shall
select loader_message1 from dbname where yourcondition;
get the mysqli result into $row and then using
$row['loader_message1'] or $row[0]
in the insert like
insert... (fld1, fld2) values (value1, value2)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.