I have 2 tables. One is general and the other is more detailed. I need to use data from both tables. Right now I am using a temporary help table to do some things and then publish the data. However I don't like this solution and I am trying to find a way to do it without the temporary table.
Here is the code so far:
DELETE FROM TableHelp INSERT INTO TableHelp (col1, col2, col3, col4) SELECT TableGeneral.col1, TableGeneral.col2, TableGeneral.col3, TableGeneral.col4 FROM TableGeneral WHERE (col2 >= @param1) AND col3 LIKE (@param2) Order By CAST( TableGeneral.col1 AS BIGINT) UPDATE TableHelp SET TableHelp.col5 = TableDetail.col10 FROM TableHelp INNER JOIN TableDetail ON TableHelp.col1 = TableDetail.col1 WHERE TableDetail.col7 LIKE 'condition'; Select * From TableHelp
This seems like it is doing what I need (not completely sure, I have a lot of data, so I didn't check everything).
Is there a way to handle this without using the help table?
Firstly I want to filter data from the general table according to the WHERE clause and @parameters. After that I want to add to the filtered data values from another table according to some condition. Just to be sure I will write what exactly I want:
TableGeneral
TableDetaill
Output should be
If I have to use the help db, than okay. However, I was curious if I can do it with some combination of conditions and functions without the table.