Query about Queries (1 Viewer)

MatthewB

Member
Local time
Today, 01:27
Joined
Mar 30, 2022
Messages
85
When one creates a query from two tables what determines which fields one includes in the query?
 

June7

AWF VIP
Local time
Today, 00:27
Joined
Mar 9, 2014
Messages
5,475
You do. Pull in fields for whatever data you want to view.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:27
Joined
Oct 29, 2018
Messages
21,477
The SELECT statement does. So, the query will include whichever fields you put in the SELECT clause of the SQL. If you're using the query designer, the Show checkbox will determine which fields are included.
 

MatthewB

Member
Local time
Today, 01:27
Joined
Mar 30, 2022
Messages
85
The SELECT statement does. So, the query will include whichever fields you put in the SELECT clause of the SQL. If you're using the query designer, the Show checkbox will determine which fields are included.
Thanks
 

June7

AWF VIP
Local time
Today, 00:27
Joined
Mar 9, 2014
Messages
5,475
Any other clauses of SQL statement you need clarification on?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 03:27
Joined
Feb 28, 2001
Messages
27,194
There are a few reasons for including given fields in a query.

You use a SELECT clause to name the fields you wish to actually show together, i.e. data to be extracted and delivered.
You use an ON clause (part of a JOIN) to name the fields that define some relationship between the participating tables.
You use a WHERE clause or HAVING clause to name fields for which you wish some selectivity to be imposed, i.e. selective inclusion or exclusion.
You use GROUP BY or ORDER BY clause to identify factors in the presentation of what you are showing when a sort or aggregation is involved.

In each case, the fields can appear in the query's clauses INDEPENDENT of whether they appear in the other clauses, with a couple of exceptions when a GROUP BY clause is involved because fields may be required in other parts of the query to support the grouping.
 

MatthewB

Member
Local time
Today, 01:27
Joined
Mar 30, 2022
Messages
85
Any other clauses of SQL statement you need clarification on?
If you want to know how basic my knowledge is at present, SQL, clause?
There are things you don't know you don't know. that's where I'm at.
 

MatthewB

Member
Local time
Today, 01:27
Joined
Mar 30, 2022
Messages
85
There are a few reasons for including given fields in a query.

You use a SELECT clause to name the fields you wish to actually show together, i.e. data to be extracted and delivered.
You use an ON clause (part of a JOIN) to name the fields that define some relationship between the participating tables.
You use a WHERE clause or HAVING clause to name fields for which you wish some selectivity to be imposed, i.e. selective inclusion or exclusion.
You use GROUP BY or ORDER BY clause to identify factors in the presentation of what you are showing when a sort or aggregation is involved.

In each case, the fields can appear in the query's clauses INDEPENDENT of whether they appear in the other clauses, with a couple of exceptions when a GROUP BY clause is involved because fields may be required in other parts of the query to support the grouping.
Thanks. I will read this closely later today. Are we talking visual basics when you say 'clause', as in a line of code?
 

GPGeorge

Grover Park George
Local time
Today, 01:27
Joined
Nov 25, 2004
Messages
1,877
Thanks. I will read this closely later today. Are we talking visual basics when you say 'clause', as in a line of code?
This SQL Statement has THREE clauses.

SELECT ThingOne
FROM tblOne
ORDER BY ThingOne

This SQL Statement has FOUR clauses.

SELECT ThingOne
FROM tblOne
WHERE ThingOne = 1
ORDER BY ThingOne
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 03:27
Joined
Feb 28, 2001
Messages
27,194
Are we talking visual basics when you say 'clause', as in a line of code?

VBA has statements usually based on keywords (DIM, PUBLIC, PRIVATE, ENUM, DECLARE, IF, THEN, ELSE, DO, WHILE, UNTIL, LOOP, END...) and the use of variables in proximity with arithmetic and logical operators to form meaningful programming formula expressions.

SQL has clauses based on use of certain keywords (SELECT, JOIN, ON, FROM, WHERE, ORDER BY, GROUP BY, HAVING, ...) and the use of table names, field names, and SOMETIMES formula expressions.
 

Users who are viewing this thread

Top Bottom