Subquery join?

I am using one subquery to do all the job.

I need a second one only to add data from some table that is not affected but the first table?

$sql = "SELECT ".$url_country.".id, ".$url_country.".asciiname, ".$url_country.".`feature code` , ".$url_country.".`country code` , ".$url_country.".`admin1 code` , ".$url_country.".`admin2 code`,geoname_countries.`country code`
FROM
 (
SELECT `country code` AS ctry, `admin1 code` AS admin1, `admin2 code` AS admin2
FROM ".$url_country."
WHERE ".$url_country.".id = ".$url_id."
) AS this
INNER
JOIN ".$url_country." ON ".$url_country.".`country code` = this.ctry
AND ".$url_country.".`admin1 code` = this.admin1
AND ".$url_country.".`admin2 code` = this.admin2

OR 

".$url_country.".`country code` = this.ctry
AND ".$url_country.".`feature code` = 'PCLI'

OR

".$url_country.".`country code` = this.ctry
AND ".$url_country.".`feature code` = 'ADM1'

OR

".$url_country.".`country code` = this.ctry
AND ".$url_country.".`admin1 code` = this.admin1
AND ".$url_country.".`feature code` = 'ADM2'
,

(SELECT *
FROM geoname_countries
)

This part simply inject data from that table no need to do any checks:

(SELECT *
FROM geoname_countries
)

And what is the question?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.