0

I have two different tables, users and complaint. I want to select values from tables users and insert it into tables complaint.

Table users:

username | name | password|

Table complaint:

complaint_ID| name | date|

This what I have tried:

$query_search = "INSERT INTO complaint (name) SELECT (name) FROM users";
Anthon
  • 69,918
  • 32
  • 186
  • 246
user1909310
  • 53
  • 1
  • 7

1 Answers1

0

First use your primary key for fetching data, for retrieving the value from your table users, write a query like:

SELECT name FROM users WHERE password=(...);

And then add this data in your second table complain write a query:

UPDATE complain SET name=(.....) WHERE complaint_ID=(....);
Luke Peterson
  • 8,584
  • 8
  • 45
  • 46