Forums

Mysql Subselect

alforau 25 Oct, 2012
Hello

Is it possible to use a subselect in place of a tablename?


I have a chronoform form with 3 DBMulti-Record-Loader = 3 chained tables

The select below works, but it contains a subselect.
SELECT `EtpInfo`.*, `CityInfo` ............ `EtpFans`.`cf_id` AS `EtpFans.cf_id`, .........`EtpFans`.`IdUser` AS `EtpFans.IdUser`, `EtpFans`.`IdEtp` AS `EtpFans.IdEtp` 
    FROM `#__etpinfo` AS `EtpInfo` 
    INNER JOIN `#__cityinfo` AS `CityInfo` ON ( EtpInfo.City_code = CityInfo.City_code ..... ) 
    LEFT JOIN   
      ( SELECT `#__etpfans`.* FROM `#__etpfans` 
        WHERE `#__etpfans`.`IdUser` = 'avalue' ) AS `EtpFans` 
      ON EtpInfo.cf_id=EtpFans.IdEtp 
    WHERE `EtpInfo`.`Country_code` = 'acode'


Without subselect I have seen only "buggy" results.

Thanks
GreyHead 25 Oct, 2012
Hi alforau,

I don't know, but I think that it is unlikely. When the query gets that complex I'd probably just use a Custom Code action for it.

Bob
This topic is locked and no more replies can be posted.