Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I use SQL to create a query?

Queries

How do I use SQL to create a query?

by  johnnymac43  Posted    (Edited  )
[pc2]
If you ask how to do something in Access, a response will often include an SQL statement for a query. [color blue]This can be daunting for new users, but it need not be.[/color]

[color green]Often, when someone decides to offer a response to a question, they will build tables and queries in a test database, using the information provided in the question. When they have a working solution they will copy the SQL generated by Access and paste it into their reply. At other times they may use an SQL statement from one of their own applications as an example, in which case the table and field names may be different to those used by the questioner.[/color]

In either case, the way to make use of the SQL is as follows:

> Copy the SQL from the reply into a text editor.

> Identify the table names and field names in the SQL and make them identical to those in your database.

> Copy the modified SQL to the clipboard.

NOTE: The following steps are based on Access 2000.

> Open your database, select 'Queries' and double click on 'Create query in Design view'. The query design window will open, titled 'Query1 : Select Query', and the 'Show Table' dialogue box will open and be given the focus.

> Close the 'Show Table' dialogue box. The query design button bar will be displayed and the 'View' button will show 'SQL'.

> Click on the 'SQL' button in the button bar. A window will open containing the highlighted text 'SELECT;'.

> Click on the 'Paste' button in the button bar. The SQL from the clipboard will overwrite the previous text, and the 'View' button will change to the datasheet icon.

> Click on the down arrow beside the 'View' button and select 'Design View'. The query design window will show all elements of the query.

[color blue]From this point you can work with the query (testing, saving, modifying, etc.) as you would with one you had built yourself.[/color]

Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top