php - Join 2 Select Statements Together With Different Where Clause & Use in While Loop -
i have 2 select statements need retrieve 2 sets of dates 1 query can while loop , return 2 dates in each row.
statement one:
select a.id, a.created_by, a.iblock_id, a.name, b.iblock_property_id, b.iblock_element_id, b.value b_iblock_element inner join b_iblock_element_property b on a.id = b.iblock_element_id b.iblock_property_id = '133'
then second 1 same different clause:
select a.id, a.created_by, a.iblock_id, a.name, b.iblock_property_id, b.iblock_element_id, b.value b_iblock_element inner join b_iblock_element_property b on a.id = b.iblock_element_id b.iblock_property_id = '134'
the b.value field returns start date when iblock_property_id 133 , end date when equals 134.
i have read use case or union unsure how work. i'd user b.value startdate , b.value enddate not sure how join these together.
then use php loop results:
$result = mysqli_query($con,"query"); while($row = mysqli_fetch_array($result)) { }
well, don't need neither case
nor union
. need inner join
. here joined query:
select a.id, a.created_by, a.iblock_id, a.name, b.value startdate, c.value enddate b_iblock_element inner join b_iblock_element_property b on a.id = b.iblock_element_id , b.iblock_property_id = '133' inner join b_iblock_element_property c on a.id = c.iblock_element_id , c.iblock_property_id = '134'
Comments
Post a Comment