0
表:qa_selltypes條件的MySQL柱
selltype_code, selltype_name
'1', 'unit'
'2', 'pound'
'3', 'box'
'4', 'gallon'
表:qa_items
item_code, item_name, selltype_code, item_price
'1', 'PS2 Keyboard', '1', '10.45'
'2', 'Screws', '3', '15.02'
'3', 'Oil', '2', '30.00'
我需要重新填充包含四個字段(單元,失速,磅,加侖)的網格,根據所述建立ITEM_PRICE與selltype_code字段的關係,其中一個示例:其餘的將它們設置爲0
DGV:
item_code, item_name, unit, box, pound, gallon
'1', 'PS2 Keyboard', '10.45', '0', '0', '0'
'2', 'Screws', '0', '0', '15.02', '0'
'3', 'Oil', '0', '30.00', '0', '0'
使用CASE語句,http://dev.mysql.com/doc/refman/5.0/en/case-statement.html –