*******************************************************
vsirsup= 68324
vsir1='%ocn%'
*******************************************************
select DISTINCT firma.cui,firma.cod_inmatriculare codj, substr(firma.denumire,1,254) firma
from firma, sediu, adresa, n_localitate n1, n_localitate n2
where (n2.siruta=?vsirsup or n1.siruta=?vsirsup) and sediu.sediu_principal <> 1
and
firma.id=sediu.id_firma and sediu.id_adresa=
adresa.id and adresa.id_siruta=
n1.id and n1.id_parinte=
n2.id and NOT exists(select 1 from stare_firma,n_stare_firma
where stare_firma.id_firma=
firma.id and stare_firma.id_stare_firma=
n_stare_firma.id and n_stare_firma.cod = 1084 )
Pentru ca in baza de date unele sedii secundare sunt cu adresa.id_siruta null, caut si dupa un sir de caractere:
select firma.cui,firma.cod_inmatriculare codj, substr(firma.denumire,1,254) firma
from firma, sediu, adresa
where adresa.id_siruta is null and lower(adresa.LOCALITATE) like ?vsir1
and
firma.id=sediu.id_firma and sediu.id_adresa=
adresa.id and NOT exists(select 1 from stare_firma,n_stare_firma
where stare_firma.id_firma=
firma.id and stare_firma.id_stare_firma=
n_stare_firma.id and n_stare_firma.cod = 1084 )
*****************************************************************
poate stie cineva sa scoata altfel
situatia asta
poate nu am pus toate conditiile
Multumesc
anticipat tuturor celor care vor face observatii