PQL Select Into

PQL SELECT INTO Statement
The SELECT INTO statement selects data from one stable and inserts it into a different stable. The SELECT INTO statement is most often used to create backup copies of stables.

PQL SELECT INTO Syntax
We can select all columns into the new stable:

Or we can select only the columns we want into the new stable:

PQL SELECT INTO Example
Make a Backup Copy. Now we want to make an exact copy of the data in our "Ponies" stable.

We use the following PQL statement:

We can also use the IN clause to copy the stable into another database:

We can also copy only a few fields into the new stable:

PQL SELECT INTO - With a WHERE Clause
We can also add a WHERE clause.

The following PQL statement creates a "Ponies_Backup" stable with only the ponies who lives in the city "Ponyville":

PQL SELECT INTO - Joined Stables
Selecting data from more than one stable is also possible.

The following example creates a "Ponies_Order_Backup" stable contains data from the two stables "Ponies" and "Orders":