全て、
多くの調査により、次のクエリを機能させることができましたが、それが何をしているのか完全には理解していません。私は今それを少し適応させる必要があるので、それをより完全に理解する必要があります.
クエリは複数のテーブルを検索して、結果ごとに 1 行 (情報の重複が多すぎる) ではなく、結果のグループごとに 1 行の結果のリストを提供します。
クエリは次のとおりです。
SELECT od_date, tbl_order.od_id, tbl_order_item.od_item_id, pd_code, item_code, pd_name, >cust, pd_type, tbl_order_item.od_item_id, tbl_order_item.test_suite_name,
MAX( IF( tbl_lab_item.test_name = 'Test 1', tbl_lab_item.test_result, NULL ) ) AS TEST1,
MAX( IF( tbl_lab_item.test_name = 'Test 2', tbl_lab_item.test_result, NULL ) ) AS TEST2,
MAX( IF( tbl_lab_item.test_name = 'Test 3', tbl_lab_item.test_result, NULL ) ) AS TEST3,
MAX( IF( tbl_lab_item.test_name = 'Test 4', tbl_lab_item.test_result, NULL ) ) AS TEST4,
MAX( IF( tbl_lab_item.test_name = 'Test 5', tbl_lab_item.test_result, NULL ) ) AS TEST5,
MAX( IF( tbl_lab_item.test_name = 'Test 6', tbl_lab_item.test_result, NULL ) ) AS TEST6
FROM tbl_item
INNER JOIN tbl_item ON tbl_lab_item.od_item_id = tbl_item.od_item_id
INNER JOIN tbl_order ON tbl_order.od_id = tbl_item.od_id
WHERE tbl_order.od_date LIKE '%$orderDate%'
AND customer_id = '%custID%'
GROUP BY tbl_lab_item.od_item_id
これにより、次の出力が得られます。
Order Date | Order ID | Item Id | <snip - other columns> | TEST1 | TEST2 | TEST 3 ...etc
09/09/2013 | 2 | 1 | | 10 | 20 | 30 ...etc
ここでやりたいことは、実際の数値を表示するのではなく、50 未満の結果を「< 50」として表示することです。「>100」についても同様です。
このロジックを上記のクエリに追加する方法、またはそれが可能かどうかさえわかりません。
あなたが提供できるどんな助けも大歓迎です。
どうもありがとう、ジェイソン