I have a select in Oracle which has subquery. I need to access values from subquery in PHP code.
For example I am able to access F.FILE_NAME and F.ID, but I need to access MI.ID and MCI.ITEM_ID as well. How to do this?
$select ="SELECT F.FILE_NAME, F.ID
FROM b_file F where exists
(SELECT '1'from b_medialib_collection_item MCI, b_medialib_item MI
WHERE MI.ID=MCI.ITEM_ID
AND F.ID=MI.SOURCE_ID
)";
I have updated my query, but the problem now is that F.FILENAME has duplicates in the table. I need to return row only once if there are rows which has the same F.FILENAME.
$select2 = "SELECT
F.FILE_NAME,MCI.COLLECTION_ID, MI.DATE_UPDATE,F.ID
FROM b_medialib_collection_item MCI
INNER JOIN b_medialib_item MI ON (MI.ID=MCI.ITEM_ID)
INNER JOIN b_file F ON (F.ID=MI.SOURCE_ID)
ORDER BY MI.DATE_UPDATE DESC";
Example
ID FILE_NAME
1 module.xls
2 doc.doc
3 foto.img
4 doc.doc
This is the basic structure of b_file table, what I want to do is to return only one record from b_file table if there are many duplicates - rows with the same FILE_NAME. In this case output would be
1 module.xls
2 doc.doc
3 foto.img