0

I have this query:

SELECT  a.apartment_id, a.building_id, a.apartment_num, a.floor, at.app_type_desc_en AS app_type_desc,
    (SELECT ROW(e.e_name, ot.otype_desc_en)
    FROM    TABLE_TENANTS t INNER JOIN TABLE_OWNERSHIP_TYPES ot ON ot.otype_id=t.ownership_type INNER JOIN TABLE_ENTITIES e ON
t.entity_id = e.entity_id
WHERE   a.apartment_id = t.apartment_id AND t.building_id = a.building_id
ORDER BY t.ownership_type DESC LIMIT 1
    ) AS t_row
    FROM    TABLE_APARTMENTS a INNER JOIN TABLE_APPARTMENT_TYPES at ON at.app_type_id = a.apartment_type LEFT OUTER JOIN TABLE_TENANTS t ON a.building_id = t.building_id AND t.entity_id=1 AND t.status=true LEFT OUTER JOIN TABLE_COMMITTEE_DELEGATE cd ON
     a.building_id = cd.building_id AND cd.entity_id=1 AND cd.status=true
                WHERE a.building_id = 1 AND (t.entity_id=1 OR cd.entity_id=1)
                ORDER BY    a.apartment_num ASC

When I'm using PHP to read the result, I use:

while($ap = pg_fetch_array($_qry)){ 

}

and trying to read "e_name", which is part of the ROW(e.e_name), but I can't succeed.

Need your ideas ... please.

2
  • Do you get an error? what is it? Please elaborate on the 'can't succeed' statement :) Commented Jul 1, 2012 at 15:09
  • Did you output the SQL query and try it in the database directly? It may be unsuccessful and $_qry may not be a resource. Commented Jul 1, 2012 at 15:09

1 Answer 1

1

use pg_fetch_assoc, to retrieve data in asoc-array; But my advice, - use PDO to work with db in PHP.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.