Join two different queries?????

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Alireza355
    New Member
    • Feb 2009
    • 86

    Join two different queries?????

    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?
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    #2
    It depends on what type of calculations you are doing beforehand, but in general you can do something like:
    Code:
    SELECT ColumnA, ColumnB, ColumnA + ColumnB as ColumnC FROM myTable...

    Comment

    • Alireza355
      New Member
      • Feb 2009
      • 86

      #3
      Thanx a lot

      Dear ChipR,

      Thank you so much for your reply.

      It works perfect...

      Comment

      Working...