MySQL IF clause
Posted on 2013-01-02
I have 2 tables:
=== fly_queue_rewards ===
| id | flight_id | date_offset | queued_time | high_priority | done | skipped |
=== fly_flights ===
| id | user_id | airport_departing | airport_arriving | date_departure | days_before | days_after | economy | business | first | deleted
and this statement:
INSERT INTO fly_queue_rewards (flight_id,queued_time) VALUES ((SELECT id FROM fly_flights WHERE deleted = '0'),'".date("Y-m-d H:i:s")."')
days_before and days_after are integers
The INSERT statement needs to be adjusted to INSERT the correct number of rows, with the correct values for date_offset, based on the data in fly_queue_rewards.
If days_before = 2 and days_after = 1, then the INSERT statement should create 4 rows, one with date_offset at -2, one with date_offset at -1, one with date_offset at 0 and one with date_offset at 0.
Many thanks for your help!