sql - Query causing values to not be included -


in following looking value in legacy database company has.

select distinct dlr.circuit_design_id "cid",                 dlr.ecckt "circuit",                 ci.location_id_2 "site id",                 ci.exchange_carrier_circuit_id "id",                 ci.rate_code "rate",                 dlr.access_customer_name "customer site name",                 adr.house_nbr || ' ' || adr.street_nm || ' ' || adr.street_suf || ' ' || adr.city_name || ' ' || adr.state_code || ' ' || adr.zip_code "customer address"        design_layout_report dlr, circuit ci, msag_addr_loc adr        ci.circuit_design_id = dlr.circuit_design_id               , ci.location_id_2 = adr.location_id              , ci.circuit_design_id in (                  select distinct circuit_design_id                         dlr_circuit_design_line                         location '%  <some value other code>   %'                  ) 

my problem comes fact adr has info of values search causing query not include values need. dlr , ci have values. how make query return , give me blank returns values not match adr entry?

you need outer join:

select distinct dlr.circuit_design_id "cid", dlr.ecckt "circuit", ci.location_id_2 "site id", ci.exchange_carrier_circuit_id "id", ci.rate_code "rate", dlr.access_customer_name "customer site name", adr.house_nbr || ' ' || adr.street_nm || ' ' || adr.street_suf || ' ' || adr.city_name || ' ' || adr.state_code || ' ' || adr.zip_code "customer address" design_layout_report dlr, circuit ci, msag_addr_loc adr ci.circuit_design_id = dlr.circuit_design_id    , ci.location_id_2 = adr.location_id (+)   , ci.circuit_design_id in (     select distinct circuit_design_id     dlr_circuit_design_line     location '%  <some value other code>   %') 

note (+). old-style join, should use ansi joins instead.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -