How do I select repeated records in SQL

Construct an SQL query for import via ODBC

After accessing your ODBC data source, use SQL query builder to construct and run a query. With SQL query builder, you construct queries that can search an ODBC data source or DBMS, retrieve specific records, and import the result records into a FileMaker Pro Advanced database file.

You can run the query immediately or save it in a field for repeated use. For more information, see Storing an SQL Query in a Field.

Note It can take some time to run complex queries or to retrieve a large number of records. It is recommended that you run the queries as batch jobs to optimize performance.

To construct a query in SQL Query Builder:

1. Select your data source.

• To import into an existing FileMaker Pro Advanced file, select File (Windows) or storage (macOS) > Import records > ODBC data source and then choose your data source. The SQL Query Builder dialog box opens (a password and username dialog box may appear first).

• If you are creating a FileMaker Pro Advanced file from the data source's records, select File (Windows) or storage (macOS) > to open. In the Open File dialog box, select the source file. Choose for File type (Windows) or Show (macOS) the option ODBC data source. Then choose your data source. The SQL Query Builder dialog box opens (a password and username dialog box may appear first).

2. Click the tab SELECT in the list box Tables on the table to be imported. The columns associated with this table appear in the list box columns.

3. Select a column that you want to include in your SQL query and click on Insert into SQL query.

This puts the SQL statement in the field SQL query inserted.

4. Add additional columns to the SQL query by clicking on the column name.

5. Click the tab WHEREto define search criteria. This reduces the number of imported data records. You can also join data from two tables.

6. To sort records before importing them, click the tab ORDER BY, then enter the name of the column you want to sort on and the sort order (ascending or descending).

7. Run the query.

You can map fields, choose to append records or create a table, or scroll through records in the data source to see which records you want to import. FileMaker Pro Advanced imports the resulting records into your database file.

Hints

• You can write an SQL statement directly in the "SQL Query" field. However, to ensure a valid SQL query, use SQL Query Builder.

Further topics

Queries to an ODBC data source from FileMaker Pro Advanced