![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Let me first describe the tables I'm working with: table1 with these columns: user_id cat_id more_data even_more_data table cat_id table1 may have one row for every cat_id in table2 which may be as many as 20 I want to make sure there is a row in table1 for every cat_id, such that every user_id has 20 rows in table. I'm trying to use an insert with a select to accomplish this. Is this even possible? Here is my query all comments appreciated. INSERT INTO table1 (cat_id) SELECT cat_id FROM table2 WHERE not exists (select cat_id from table1 where table1.user_id = 9999 ) where table1.user_id = 9999 The way I read this like this: insert into table1's cat_id column all cat_id's that exist in table2 but not in table2 for a given user_id. But this query fails with a not properly ended error. Oracle 9i |
#3
| |||
| |||
|
|
Let me first describe the tables I'm working with: table1 with these columns: user_id cat_id more_data even_more_data table cat_id table1 may have one row for every cat_id in table2 which may be as many as 20 I want to make sure there is a row in table1 for every cat_id, such that every user_id has 20 rows in table. I'm trying to use an insert with a select to accomplish this. Is this even possible? Here is my query all comments appreciated. INSERT INTO table1 (cat_id) SELECT cat_id FROM table2 WHERE not exists (select cat_id from table1 where table1.user_id = 9999 ) where table1.user_id = 9999 The way I read this like this: insert into table1's cat_id column all cat_id's that exist in table2 but not in table2 for a given user_id. But this query fails with a not properly ended error. Oracle 9i |
#4
| |||
| |||
|
|
Let me first describe the tables I'm working with: table1 with these columns: user_id cat_id more_data even_more_data table cat_id table1 may have one row for every cat_id in table2 which may be as many as 20 I want to make sure there is a row in table1 for every cat_id, such that every user_id has 20 rows in table. I'm trying to use an insert with a select to accomplish this. Is this even possible? Here is my query all comments appreciated. INSERT INTO table1 (cat_id) SELECT cat_id FROM table2 WHERE not exists (select cat_id from table1 where table1.user_id = 9999 ) where table1.user_id = 9999 The way I read this like this: insert into table1's cat_id column all cat_id's that exist in table2 but not in table2 for a given user_id. But this query fails with a not properly ended error. Oracle 9i |
#5
| |||
| |||
|
|
Let me first describe the tables I'm working with: table1 with these columns: user_id cat_id more_data even_more_data table cat_id table1 may have one row for every cat_id in table2 which may be as many as 20 I want to make sure there is a row in table1 for every cat_id, such that every user_id has 20 rows in table. I'm trying to use an insert with a select to accomplish this. Is this even possible? Here is my query all comments appreciated. INSERT INTO table1 (cat_id) SELECT cat_id FROM table2 WHERE not exists (select cat_id from table1 where table1.user_id = 9999 ) where table1.user_id = 9999 The way I read this like this: insert into table1's cat_id column all cat_id's that exist in table2 but not in table2 for a given user_id. But this query fails with a not properly ended error. Oracle 9i |
![]() |
| Thread Tools | |
| Display Modes | |
| |