0

I want to write an sql command in PHP in which I want to insert a data in a particular column having particular data already present in that row.Here is the image where I want to insert 1_day_device to a particular 1_day_id

image

Also, how can I autodelete a row after a certain time? Like, in the image I want to delete one complete row after one day. I am using PHP for server-side.

  • Seems like you are looking for `replace` query –  Jul 03 '18 at 03:53
  • See: https://dev.mysql.com/doc/refman/5.7/en/event-scheduler.html – Will B. Jul 03 '18 at 04:11
  • What have you tried so far? – Will B. Jul 03 '18 at 04:13
  • I am getting data from two different sources. First, I get 1_day_id from one source then I get 1_day_device from another source. Now "996609" should get "bdb*********" but right now it's in another row. Similarly, for id "1595281" I want to insert "3cf4********" in that row. – Jeetu Routela Jul 03 '18 at 04:18

1 Answers1

0

I think you are looking for the update query with particular 1_day_id. Try with the below query.

UPDATE your_table_name SET 1_day_device='".$device."' WHERE 1_day_data='".$data."'

For delteting the records please follow this link Delete row from database automatically after 24 hours

shubhangee
  • 529
  • 3
  • 10
  • Please do not use `mysql_**` based functions, as they are no longer supported, use `mysqli_***` or `PDO` instead. Additionally please reference the use of [prepared statements](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) to avoid SQL injection. – Will B. Jul 03 '18 at 04:15