Another couple of excerpts that confused me here too:
This bit of SQL is obviously checking we just get 1 row returned for the assumed primary key
SELECT count(*) FROM olap_delivery_data3 WHERE olap_delivery_data3.seq_number='138376' =>Count=1
This SQL appears to be going and retrieving all the fields for the parent record, utilising the primary key sequence number:
select * from ( select a.*, rownum as rnum from ( SELECT olap_delivery_data3.* FROM olap_delivery_data3 WHERE olap_delivery_data3.seq_number='138376' ) a where rownum <= 1 ) where rnum >= 1=>Count=1
This is where is gets confusing:
I don't understand why this piece of SQL goes and runs, effectively returning a count of the total number of child records that match ALL records in the parent table.
Shouldn't it just be delimiting here with an additional where clause on the SEQ_NUMBER?
SELECT count(*) FROM olap_delivery_notes3 LEFT JOIN olap_delivery_data3 ON (olap_delivery_data3.seq_number=olap_delivery_notes3.delivery_data_seq) =>Count=2076
These are the preceding steps to the earlier post, but it's obviously following a similar vane, in that it doesn't seem to want to pass through a where clause to the child selection query.