0

I have a table nameValue that has 5 columns (Id,val,firstName,lastName,age). I use a select statement that gives firstName,lastName, age in multiple rows, lets say it returns 5 rows. Id is Auto-Increment. I want to add val to each of the 5 rows returned.

$val=55; INSERT INTO nameValue (val,firstName,lastName,age) VALUES($val, SELECT fName,lName,age FROM nameAge WHERE age<25); something like this where we are insert same variable $val to each of the 5 rows returned by the select statement.

Shanu
  • 95
  • 11

1 Answers1

0

Thats the wrong way. Try this -

INSERT INTO nameValue (val,firstName,lastName,age)
SELECT $val, fName,lName,age FROM nameAge WHERE age < 25
Sougata Bose
  • 31,517
  • 8
  • 49
  • 87