Actually I have the following code:
$stmt = $pdo->prepare('SELECT id, city, date_created FROM my_table WHERE city = :city ORDER BY date_created DESC LIMIT 1');
$stmt->execute(array(':city' => $city));
I try to explain what I want to do:
Check if there's a row containing
all
in columncity
.If so, check if the date of this row in
date_created
ist newer that the date in the newest entry for the query above. If so, select this row, else select the newest entry of the query below.
I hope you understand what I want to do. Unfortunately I'm not familiar with if/else statements in SQL.
Can anybody help me?