# Using SQL Select Statements

Inaport allows you to use SQL SELECT statements to extract data from the source database.

SQL Select statements are a powerful mechanism for selecting data from relational databases. They can be used to:

- select some or all the fields from a table
- join two or more tables together, then select fields from the joined tables
- order the records that have been selected
- use calculations to create new fields in the data

Entire books have been written about the use of SQL; clearly a full discussion is beyond the scope of this document. The most common SQL statement is to select all the fields from a table:

SELECT * FROM tableName

where "*" means all fields. This can be refined to select only some fields:

SELECT field1, field2, field3 FROM tableName

We can join tables together and select fields from either or both tables. If the fields have the same name, we use the name of the table as well to make sure we get the correct one:

SELECT table1.field2, field3, table2.feld5 FROM table1, table2

We can apply a WHERE condition to select only those records that meet a certain condition:

SELECT field1, field2 FROM table1 WHERE (field3 = 'South')

SQL statements can be much more powerful than the examples shown here. If you are not familiar with SQL, you may wish to consult an introductory database book. You can also experiment easily with Inaport - type in your SQL statement and click the APPLY button to see what happens. If what you get is not what you want, edit the statement and click APPLY again.

Some points to note on using SQL:

- SQL can be used with all data types except CSV files and ACT! databases.
- The capabilities of the SQL statements vary somewhat depending on the data source. Some of the more advanced features of SQL may not be supported
- The syntax for using SQL with Excel spreadsheets is a little unusual - see Using SQL with Excel for details.
- When building your SQL statement in the text box in the wizard, you can use the enter key to break the statement up:
  SELECT field1 FROM table1
  WHERE (field2 = 24)