SELECT
nd.id, nd.location_city, nd.location_street, nd.location_house, nd.location_flat, nd.location,
(SELECT
ls.name FROM location_cities lc
JOIN location_boroughs lb ON
lb.id = lc.boroughid
JOIN location_districts ld ON
ld.id = lb.districtid
JOIN location_states ls ON
ls.id = ld.stateid
WHERE
lc.id = nd.location_city) AS area_woj,
(SELECT
ld.name FROM location_cities lc
JOIN location_boroughs lb ON
lb.id = lc.boroughid
JOIN location_districts ld ON
ld.id = lb.districtid
JOIN location_states ls ON
ls.id = ld.stateid
WHERE
lc.id = nd.location_city) AS area_pow,
(SELECT
lb.name FROM location_boroughs lb JOIN location_cities lc ON lc.boroughid =
lb.id WHERE
lc.id = nd.location_city) AS area_gmi,
(SELECT Concat('ls.ident', '_', 'ld.ident', '_', 'lb.ident', '_', 'lb.type')
FROM location_cities lc
JOIN location_boroughs lb ON
lb.id = lc.boroughid
JOIN location_districts ld ON
ld.id = lb.districtid
JOIN location_states ls ON
ls.id = ld.stateid
WHERE
lc.id = nd.location_city) AS area_terc,
(SELECT
lc.name FROM location_cities lc WHERE
lc.id = nd.location_city) AS area_city,
(SELECT lc.ident FROM location_cities lc WHERE
lc.id = nd.location_city) AS area_simc,
(SELECT tu.cecha FROM teryt_ulic tu WHERE
tu.id = nd.location_street) AS address_cecha,
(SELECT (CASE WHEN ls.name2 IS NOT NULL THEN Concat('ls.name2' , ' ', '
ls.name') ELSE
ls.name END) AS name
FROM location_streets ls WHERE
ls.id = nd.location_street) AS address_ulica,
(SELECT tu.sym_ul FROM teryt_ulic tu WHERE
tu.id = nd.location_street) AS address_symul,
(CASE WHEN (nd.location_flat IS NULL OR nd.location_flat = '') THEN nd.location_house ELSE
Concat('nd.location_house ', '/', 'nd.location_flat') END) AS address_budynek,
(SELECT zip FROM pna WHERE pna.cityid = nd.location_city
AND (pna.streetid IS NULL OR (pna.streetid IS NOT NULL AND pna.streetid = nd.location_street)) LIMIT 1) AS location_zip,
ports,
nd.longitude, nd.latitude, nd.status, nd.netnodeid,
(CASE WHEN nd.invprojectid = 1 THEN nn.invprojectid ELSE nd.invprojectid END) AS invprojectid
FROM netdevices nd
LEFT JOIN netnodes nn ON
nn.id = nd.netnodeid
WHERE EXISTS (SELECT id FROM netlinks nl WHERE nl.src =
nd.id OR nl.dst =
nd.id)
BŁĄD: relacja "teryt_ulic" nie istnieje
LINE 21: (SELECT tu.cecha FROM teryt_ulic tu WHERE tu...
^
********** Błąd **********
BŁĄD: relacja "teryt_ulic" nie istnieje
Stan SQL: 42P01
Znak: 1628