1

荻テーブル

number    name         price         month         year
152       cheese       25            10            12
153       yogurt       12            10            12
152       cheese       22            11            12
153       yogurt       15            11            12
154       apples       30            11            12 

現在、2 か月間で行を比較する次のクエリがあります。

select a.price as p1, b.price as p2, a.distributor, a.number, a.name, (a.price - b.price) as pdiff from ogi a, ogi b where a.number = b.number and a.month = '" . $from_date . "' and b.month = '" . $to_date . "' and a.distributor = '" . $distributor . "'

前月に行が存在しなかったかどうかを確認し、「存在しませんでした」またはそれらの行に沿って何かをエコーし​​ようとしています。

では、番号 154 (上記の表にある)の前の月に行が存在しなかったかどうかを確認し、「存在しませんでした」とエコーする方法を教えてください。

助けてくれてありがとう!

4

3 に答える 3