jen
jen

Reputation: 1

How to use select statement to insert values on a table

I am trying to insert theses values to my table student but I have an error

insert into student(first_name,last_name,student_number,professor_id)
  values(Eden,Yuan,323744573, 
  select professor_id from PROFESSORS where professor_name =  'Chu ')

I get an error

saying missing expression

Upvotes: 0

Views: 26

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133370

you can use this way (assuming that professor_id is the column you need)

insert into student(first_name,last_name,student_number,professor_id) 
select 'Eden', 'Eden', 323744573, column_professor_id 
from PROFESSORS where professor_name = 'Chu ' ;

(In your query is missing the column in the select )

Upvotes: 2

Related Questions