SQL from query or table?

  • Thread starter Thread starter Gibson
  • Start date Start date
G

Gibson

Is it more advantagous to use SQL from a table to supply data to a control
on a form as in the sql statement below:
SELECT DISTINCT flkp1.Field1 FROM flkp1;

Or sql from a query as below:
SELECT DISTINCT qry1.Field FROM qry1;

Is one faster the other? Any other reasons to use one over the other?
 
A query is just a SQL statement itself, so when you run SQL against a query,
you are using SQL twice: once in the query and again in your SQL statement.
When running SQL against the table directly, you eliminate one layer of SQL
statement(s).

Having said that, there are times when a single SQL statement is so complex
(e.g. having complex domain aggregate functions inside it) that it makes
sense to set up a SELECT query, then another query that uses the first query
as its source (like your second example).
 
Back
Top