insert into community(community_id, name, short_description)
values(getnextid('community'),'Courses','Courses');

select F.X || ',' || C.community_id || ');' AS test from community C, (select 'insert into community2community (id, parent_comm_id, child_comm_id) values(' || getnextid('community2community') || ',' ||  community_id AS X from community where name='Courses' ) F where C.name like 'EY%';

select 'insert into communities2item (id,community_id,item_id) values(' || getnextid('communities2item') || ',' || community_id || ',' || I.item_id || ');'
from
        (select item_id from
                (select community_id FROM community where name like 'EY%' OR name like 'EP%' or name like 'EC%' or name like 'S%') C,
                 communities2item CI
                 where C.community_id=CI.community_id Group by item_id) I,
        community C
where C.name='Courses'

