Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.2.1 | 

INSERT Using Subqueries


You can insert data by including a query as one of the VALUES items in the INSERT statement.


INSERT INTO table_name [ ( attribute_list ) ]
VALUES ( value_listquery_statement ) [ ; ]

  • table_name : Specifies the name of the table where the data is to be inserted.
  • attribute_list : Specifies the column names for the data to be inserted.
  • value_list : Specifies the values corresponding to the columns of the attribute_list.
  • query_statement : Defines a subquery. The result of the subquery must be a value corresponding to one of the columns.

The following is an example of inserting the information about Wang Ki-chun, 2008 Beijing Olympics silver medalist in men's 73kg Judo into the athlete table.

INSERT INTO athlete VALUES (16800, 'Wang Ki-chun','M',SELECT code FROM nation WHERE name ='Korea', 'Judo');