--兩個截然不同
select
isnull(max(ti_goods_count)-
sum(isnull(sl_count,0)),0) as ti_goods_count, isnull(max(ti_goods_weight)-
sum(isnull(sl_weight,0)),0) as ti_goods_weight, isnull(max(ti_goods_body)-
sum(isnull(sl_body,0)),0) as ti_goods_body, isnull(max(ti_prepay_price)-
sum(isnull(sl_prepay_price,0)),0) as ti_prepay_price, isnull(max(ti_return_price)-
sum(isnull(sl_return_price,0)),0) as ti_return_price, isnull(max(ti_arrive_price)-
sum(isnull(sl_arrive_price,0)),0) as ti_arrive_price, isnull(max(ti_month_price)-
sum(isnull(sl_month_price,0)),0) as ti_month_price, isnull(max(ti_sum_price)-
sum(isnull(sl_sum_price,0)),0) as ti_sum_price, isnull(max(ti_back_is_price)-
sum(isnull(sl_isback,0)),0) as ti_back_is_price, isnull(max(ti_back_isnot_price)-
sum(isnull(sl_notback,0)),0) as
ti_back_isnot_price,
isnull(max(ti_back_price)-
sum(isnull(sl_back_price,0)),0) as
ti_back_price
from t_send_list right
join t_ticket_info on ti_id = sl_ti_id where sl_ti_id=
2317
--------------------------------
select
isnull(max(ti_goods_count)-
sum(isnull(sl_count,0)),0) as ti_goods_count, isnull(max(ti_goods_weight)-
sum(isnull(sl_weight,0)),0) as ti_goods_weight, isnull(max(ti_goods_body)-
sum(isnull(sl_body,0)),0) as ti_goods_body, isnull(max(ti_prepay_price)-
sum(isnull(sl_prepay_price,0)),0) as ti_prepay_price, isnull(max(ti_return_price)-
sum(isnull(sl_return_price,0)),0) as ti_return_price, isnull(max(ti_arrive_price)-
sum(isnull(sl_arrive_price,0)),0) as ti_arrive_price, isnull(max(ti_month_price)-
sum(isnull(sl_month_price,0)),0) as ti_month_price, isnull(max(ti_sum_price)-
sum(isnull(sl_sum_price,0)),0) as ti_sum_price, isnull(max(ti_back_is_price)-
sum(isnull(sl_isback,0)),0) as ti_back_is_price, isnull(max(ti_back_isnot_price)-
sum(isnull(sl_notback,0)),0) as
ti_back_isnot_price,
isnull(max(ti_back_price)-
sum(isnull(sl_back_price,0)),0) as
ti_back_price
from t_send_list right
join t_ticket_info on ti_id = sl_ti_id where ti_id=
2317
如果未作發貨則,第一條語句會有資料,第二條將沒有資料,雖然是相同的意思ti_id等同於sl_ti_id,但外來鍵為空時就有意外了。!!
mysql 外來鍵為空 MySQL外來鍵查詢返回空
我有三張桌子 我們來乙個demo organization field type null key default extra id int 11 no pri null auto increment org name varchar 100 no null org type varchar 100...
測試以兩個外來鍵為復合主鍵的表,兩個外來鍵空值情況
多表關聯的情況下,刪除主表的一條資料,同時修改與主表關聯的從表對應資料,如 tbl a表,tbl b表,兩表互動表tbl a b。當tbl a中的資料某條資料刪除時,需要先清除tbl a b表中對應的資料才能刪除tbl a中的資料,但有時不想刪除tbl a b的資料,就需把tbl a b中對應的a ...
Oralce查詢所有關聯某字段為外來鍵的表
在程式或者手動執行刪除表資料時,經常遇到關聯外來鍵無法刪除而報錯的情況。若是自己建的表還好,最慘的就是接手別人的專案維護,這時想要快速定位以某個字段作為外來鍵的所有表,可以利用以下語句查詢 select a.table name,a.column name from user cons column...