SELECT guides.namer as document, print_form.nm as print_form, script as script FROM "DBA"."print_form", "DBA"."print_forms_usr" , guides Where script like '%18%' and (("DBA"."print_form"."dw_header" = "DBA"."print_forms_usr"."nm" and "DBA"."print_forms_usr"."header_id" = 0) or ("DBA"."print_forms_usr"."header_id" > 0 and "DBA"."print_form"."dw_header" in (Select "p_f_usr"."nm" From "DBA"."print_forms_usr" p_f_usr Where p_f_usr.id = "DBA"."print_forms_usr"."header_id"))) and print_form.id_guide=guides.id;