hoonew wrote:
I need to do in SQL the following psuedo-code, and I'm stuck:
IF ((COUNT(*) FROM a WHERE column_a=1)>0)
THEN
INSERT INTO TABLE b
ENDIF
create table a (column_a integer);
create table b (foo varchar(10));
insert into a (column_a) values (1), (1);
insert into b (foo)
select distinct 'foo' as foo
from a where column_a = 1;
....one record inserted, because of distinct.
insert into b (foo)
select distinct 'foo' as foo
from a where column_a = 2;
....zero records inserted, because no records in `a` match.
Bill