Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

CHAPTER 8 Inserting Data > Insert by Queries

Insert by Queries

Inserting data from queries eliminates the VALUES clause—doing so actually replaces the clause with the query. The default and override signatures remain the same. Matching the columns returned by the SELECT statement replaces matching VALUES clause columns against the override column list or table definition.

The prototype changes slightly for the INSERT statement when the source becomes the results from a query rather than a list of values. The VALUES keyword must be dropped when you use a query or the INSERT statement fails.

The following prototype works for Oracle and MySQL databases and includes options for joining more than one table on various conditions and uses ANSI SQL-92 syntax:

image INSERT INTO table_name

  [( column_name1, column_name2, …)]


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial