|
Syntax for basic SQL statements in Access. SQL = Structured Query Language
Here is basic SQL for a query.
SELECT fieldlist
FROM tablename
IN 'path\anotherdatabase.accdb'
WHERE criteria
GROUP BY fieldlist
HAVING criteria for fields that are grouped (aggregated)
ORDER BY fieldlist;
Where:
fieldlist
is a list of fields or expressions separated by a comma
path\anotherdatabase.accdb
is a fully qualified name of a file,
delimited with a single quote
criteria
is how you want to limit the records returned
The SELECT clause is always required.
All other clauses are optional if SELECT only contains expressions
that don't require a table to calculate
You can create a query in any database from this SQL without using any table -- so there is only a SELECT clause because all the columns use calculated expressions that don't depend on any table. All the expressions report information pertaining to the current date.
SELECT Date() AS DateToday , Format(Date(),"ddd") AS DayName , Format(Date(),"d") AS DayNumberInMonth , Format(Date(),"mmmm") AS MonthName , Format(Date(),"yyyy") AS Yr;
Understanding basic SQL is very helpful
Access has a wonderful graphical query designer! Good to take advantage of it. However, realize that what Access stores to get the data is the SQL statement, so if you plan to develop, good to switch to SQL view to see how everything is specified.
If you like this page, please let me know, thank you. Donations are always appreciated
Here's the link for this page in case you want to copy it and share it with someone:
https://msaccessgurus.com/VBA/SQL_BasicSyntax.htm
or in old browsers:
http://www.msaccessgurus.com/VBA/SQL_BasicSyntax.htm
Let's connect and team-develop your application together. I teach you how to do it yourself. My goal is to empower you.
While we build something great together, I'll pull in code and features from my vast libraries as needed, cutting out lots of development time, and I'll give you lots of links to good resources.
SQL is important to get familiar with.
I'm happy to help.
Email me at training@msAccessGurus
~ crystal
the simplest way is best, but usually the hardest to see