By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,217 Members | 1,297 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,217 IT Pros & Developers. It's quick & easy.

Join two different queries?????

Alireza355
P: 86
Dear all

I have one query which selects some items from my main table and inserts the results into a fresh temporary table. in this table, there is a column that remains empty to be filled with the results of a second query:

I also have another UPDATE query that updates the empty column with the result of adding columnA + columnB of the newly-filled table.

Sorry, I am not so good in English. Let me give an example:

In the new table, there are 3 columns: ColumnA , columnB and columnC
The table is fresh, and there is nothing in it.
The first query, selects some information and inserts them into the new table:

ColumnA=12500
ColumnB=6000
ColumnC=Null

Now the second query updates ColumnC to 6500

I had to do this because the first query sorts the records in a quite complicated manner and puts them into the new fresh table. Now the result of the calculation becomes meaningful. The sorting of the first query should be done FIRST and then the calculation should be done. of course if the calculation is done at the same time each row is inserted into the new table, nothing seems to be wrong theoretically to me.


Since there are thousands of records, is there a way I can join these two queries into a single query to save time?
Apr 22 '09 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 1,287
It depends on what type of calculations you are doing beforehand, but in general you can do something like:
Expand|Select|Wrap|Line Numbers
  1. SELECT ColumnA, ColumnB, ColumnA + ColumnB as ColumnC FROM myTable...
Apr 22 '09 #2

Alireza355
P: 86
Dear ChipR,

Thank you so much for your reply.

It works perfect...
Apr 23 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.