==表结构
CREATE TABLE trade_retail_bill
(
id
bigint(20) NOT NULL,
bill_no
varchar(32) COLLATE utf8_general_ci DEFAULT NULL ,
bill_status
varchar(2) COLLATE utf8_general_ci DEFAULT NULL,
****
PRIMARY KEY (id
),
UNIQUE KEY bill_no
(bill_no
),
KEY idx_retail_bill_no
(bill_no
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci
CREATE TABLE trade_retail_bill_line
(
id
bigint(20) NOT NULL,
bill_id
bigint(20) DEFAULT NULL ,
*****
PRIMARY KEY (id
),
KEY idx_retail_line_sku_id
(sku_id
),
KEY idx_retail_line_goods_id
(goods_id
),
KEY idx_retail_line_bill_id
(bill_id
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci
==查询语句
SELECT *****
FROM
“trade_retail_bill” “trade_retail_bill”,
“trade_retail_bill_line” “trade_retail_bill_line”
WHERE
“trade_retail_bill”.“bill_status” IN (‘05’)
AND (
“trade_retail_bill”.“id” = “trade_retail_bill_line”.“bill_id”
);