Home > Enterprise >  Insert into when username matches
Insert into when username matches

Time:11-10

Suppose my table user_info has 2 columns, one is #username and another one is #info.

Now I already made a query "INSERT INTO user_info(username) value('')

How can I make another query to put data on column #info for the same username?? Because after the first query I'll have null for the column #info I believe.

Just to clarify, I don't get the #info when I have the username. Each user will get their info later. So I can't put then on the same query.

CodePudding user response:

In that case, you need to update the row, simply using update on where the username exist

From documentation:

UPDATE table_name
SET column1 = value1,
    column2 = value2,
    ...
WHERE condition;

Your case:

UPDATE user_info 
SET info='new_information' 
WHERE username='existing_username'
  • Related