I'd like to output two rows into one and change the output based on the values
SQL syntax:
SELECT *
FROM course
LEFT OUTER JOIN located ON course.course_id = located.course_id
LEFT OUTER JOIN city ON city.city_id = located.city_id
PHP syntax:
while ($row=$result->fetch_assoc()) { ?>
<div class="col-lg-4 col-md-6" style="margin-bottom: 20px">
<div class="card bg-black" style="text-align: center;">
<div class="card-body">
<h3 class="card-text text-white"><?= $row['name']?></h3>
<p class="text-danger"><?= $row['city_name'];?></p>
</div>
</div>
</div>
<?php
}
?>
The output:
How I'd like it to be:
But if it is only one city it would show the name of the city which happened to be "City 1" or "City 2".


COUNT(*)in SQL?IF(COUNT(*) > 1, COUNT(*), Name) as citynameIs this what you are looking for?