0

I want to add weight value to row 2. How do I do that? I tried to do the following but it gives me an error:

INSERT INTO name(member_id, weight) VALUES(2,55.6);

What is the mistake that I'm having?

enter image description here

1
  • Hi, welcome to StackOverflow. Do you mean you are trying to change the weight column value of the second row? If so, you need to update the row by member_id column. If you're trying to add a column to an existing table, you'll need an ALTER TABLE statement, something like: ALTER TABLE table ADD [COLUMN] column_name column_definition [FIRST|AFTER existing_column];. You can find more info here: Commented Dec 13, 2020 at 9:02

4 Answers 4

1

If you're updating a specific row you need to use the UPDATE command

UPDATE talbename
   SET weight =55.6
   WHERE member_id = 2
Sign up to request clarification or add additional context in comments.

Comments

1

You can use the UPDATE clause and use a WHERE condition to target a particular row -

UPDATE fromis_9
SET weight = 2
WHERE member_id = 2;

2 Comments

Out of range value for column 'weight' at row 1, this is the error
Well, your CREATE TABLE statement (from your screenshot) shows that you didn't add the weight column at the time of creating the table. Did you add in the correct data type when you added it in later?
1

INSERT INTO clause is used for inserting new records. To Update an existing record, UPDATE clause is used.

UPDATE fromis_9 SET weight = 55.6 WHERE member_id = 2;

Comments

0

Hi I think you should use INSERT INTO table where condition(member.id=2) please refer to https://www.w3schools.com/sql/sql_insert_into_select.asp Its better to learn how to read documentation than wait for complete answer ;)

1 Comment

I agree with answer below, i forgot that if you are inserting something in existing row you need to use update instad of insert (Too much spring)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.