Subquery Help Please :-Þ
Posted: Mon Jan 21, 2008 1:58 pm
I have two tables with the same exact columns. I want to insert all data from all columns from table 1 (curldata) to table 2 (coldowl) IF the value of 'ticker' does not exist in table 2 and it meets specified parameters. So far this is what i have:
[sql] IF NOT EXISTS (SELECT 'ticker'FROM curldataWHERE annsales >= '100'AND multiplier <= '17'AND multiplier > '0'AND bookval > '0'AND multiplier * bookval <= '24.5'AND past_5_earnings >= '16.5'AND curass / total_cur_liabilities >= '2')INSERT INTO 'coldowl' (SELECT *FROM curldataWHERE annsales >= '100'AND multiplier <= '17'AND multiplier > '0'AND bookval > '0'AND multiplier * bookval <= '24.5'AND past_5_earnings >= '16.5'AND curass / total_cur_liabilities >= '2' ) ; [/sql]
This is my first subquery attempt. Any help is appreciated.
[sql] IF NOT EXISTS (SELECT 'ticker'FROM curldataWHERE annsales >= '100'AND multiplier <= '17'AND multiplier > '0'AND bookval > '0'AND multiplier * bookval <= '24.5'AND past_5_earnings >= '16.5'AND curass / total_cur_liabilities >= '2')INSERT INTO 'coldowl' (SELECT *FROM curldataWHERE annsales >= '100'AND multiplier <= '17'AND multiplier > '0'AND bookval > '0'AND multiplier * bookval <= '24.5'AND past_5_earnings >= '16.5'AND curass / total_cur_liabilities >= '2' ) ; [/sql]
This is my first subquery attempt. Any help is appreciated.