Subject: Access VBA - SQL question.
Posted By: Raelz Post Date: 2/9/2004 1:55:17 PM
In the book "Beginning Access 2000 SQL" (Great book so far btw) I'm hitting a snag.  

In chapter 8 we are dynamically building SQL statements. The value assigned to the SELECT statement is always prefixed with "s."

ie:

strSELECT = "s.tblSales" or strSELECT = "S.*"

Why is it prefixed?

Any help is appreciated,

Thanks


-Raelz-
Reply By: Ben Reply Date: 2/10/2004 5:32:43 AM
The table would have been defined as s, this saves on both typing and typing mistakes
Reply By: Raelz Reply Date: 2/10/2004 10:45:39 AM
As in, using a dim state to declare s to be a table?

-Raelz-
Reply By: Braxis Reply Date: 2/10/2004 3:51:20 PM
Raelz

It's what's known as an alias in SQL.

The full SQL statement would be something like this:

SELECT s.fldCost
FROM tblSales s

The bit in bold is saying; wherever you see 's' in the query replace it with tblSales.

As Ben says it reduces the amount of typing you have to do. Personnally, I never(*) use them as it reduces the readability of the query.

*Well, not quite never! Sometimes you have to use them to make the query work - for example if you need to bring the same table into a query more than once


Brian Skelton
Braxis Computer Services Ltd.
Reply By: Raelz Reply Date: 2/10/2004 10:28:57 PM
Ah, Thanks to both of you, really cleared that bit up.

-Raelz-

Go to topic 9566

Return to index page 951
Return to index page 950
Return to index page 949
Return to index page 948
Return to index page 947
Return to index page 946
Return to index page 945
Return to index page 944
Return to index page 943
Return to index page 942