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?
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?
Comment