473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Select from multiple queries/tables?

Can I select from multiple tables/queries in a single SQL statement?

For example:

SELECT [this], [that], [otherThing]
FROM qryThis, qryThat, tblOtherThing

Does this work only with Jet, or does SQL just work like this?

The specific problem I'm trying to solve is compiling a RecordSource for a
report that includes a formatted Name-Address block that looks like
something like this:

Mr. John Person
1234 South Street
Anytown, CA 96723

In the below SQL statement, [qryNameAddressBlock] gathers all the address
info (as [Block]) with the help of a function to skip any blank lines and
insert carriage returns in the right place.

SELECT [tblTxJournal].[Amount], DateValue([tblTxJournal].[TxDate]) AS
InvoiceDate, [tblTxJournal].[Entity_ID], [tblTxJournal].[Tx_ID],
[qryNameAddressBlock].[Block] AS Customer
FROM tblTxJournal, qryNameAddressBlock
WHERE ([tblTxJournal].[Tx_ID] = 12504);

Will this work if the database is upsized to SQL Server?

Feb 4 '06 #1
2 2973
>From a design view in a query, can you link your queries and tables
together? Find a common link between all your data sources. It seem
tblTxtJournal should have a customer ID and link it to the
qeyNameAddressBlock.

Have extensive experience in developing accounting software. I would
put a copy of your customer address in your invoice history file. At
the time of the invoice, the address was this. If you change their
address, change the customer master, the old invoices should print with
the old address, the new invoices should have the new address.

Feb 4 '06 #2
> >From a design view in a query, can you link your queries and tables
together? Find a common link between all your data sources. It seem
tblTxtJournal should have a customer ID and link it to the
qeyNameAddressBlock.
Yes, but my main question was regarding the syntax of the SQL statement:

SELECT [this], [that], [otherThing]
FROM qryThis, qryThat, tblOtherThing

Which I assume is perfectly fine (since it works), but I'm curious if this
is something peculiar to Jet - or is it acceptable SQL grammar which will
also work with other databases, such as MS SQL Server, Oracle?
Have extensive experience in developing accounting software. I would
put a copy of your customer address in your invoice history file. At
the time of the invoice, the address was this. If you change their
address, change the customer master, the old invoices should print with
the old address, the new invoices should have the new address.


Good advice, to be sure, and that's exactly how it works:

All addresses are stored in a separate table. Each customer record can have
any number of addresses, one of which is selected as the primary, or billing
address. Invoices are generated dynamically (using the selected address),
automatically converted to PDF and emailed, and a hyperlink to the pdf file
is automatically inserted into another table which is displayed in a subform
datasheet. So old invoices are a click away and will show whatever address
was selected when the invoice was created.
Feb 4 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Beyonder | last post by:
I have five tables in my database, there are actually NO common fields between them, not even a KEY or ID or anything like that, except for the "body" of a blob field. and that text is not...
6
by: Michael | last post by:
I have two tables with a 1-many relationship. I want to write a select statement that looks in the table w/many records and compares it to the records in the primary table to see if there are any...
17
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by...
10
by: serge | last post by:
Using "SELECT * " is a bad practice even when using a VIEW instead of a table? I have some stored procedures that are identical with the difference of one statement in the WHERE clause. If I...
0
by: rayone | last post by:
Hi folks. I need advice. 2 options, which do you think is the better option to display/retrieve/report on the data. Keep in mind reporting (Crystal), SQL Performance, VB Code, usability,...
13
by: andro | last post by:
Hi everybody! I have several tables from which I want to exract the SAME value (along with other referenced data). All the values are in the same column within the tables. How can I achieve...
3
by: ivanov.alexei | last post by:
It's my first post and first DB application. Environment: MFC DAO, MS Access database I want to have several tables which have links to the fields to other tables. The following example explains...
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
6
by: BobRoyAce | last post by:
Let's say that I am performing a bunch of insert/update queries within a transaction that is created as follows: Dim cnn As New SqlClient.SqlConnection(My.Settings.GRPConnectionString)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.