Shigeshi Hitoshi > 11-09-13, 05:40 PM
SELECT F21, F22, F23, F24, F25, F26, F27, F28, F29, F30
FROM Journal_Import
WHERE Journal_Import.F30 or Journal_Import.F21;
INSERT INTO test1 ( SoHD, NgayNhan, TenKhachHang, MST, MatHang, GiaChuaThue, ThueSuat, Thue, GhiChu, LoaiHD )
SELECT F21, F22, F23, F24, F25, F26, F27, F28, F29, F30
FROM Journal_Import
WHERE Journal_Import.F30 or Journal_Import.F21 AND NOT EXISTS ( SELECT SoHD
FROM test1
WHERE test1.SoHD = Journal_Import.F21 or test1.LoaiHD = Journal_Import.F30);
tt1212 > 11-09-13, 10:18 PM
Shigeshi Hitoshi > 12-09-13, 09:29 AM
paulsteigel > 12-09-13, 09:46 AM
(10-09-13, 03:13 PM)Shigeshi Hitoshi Đã viết: mình dùng query nhiều lắm vì yêu câu là không dùng form thì đâu dùng vba được nên phái ráng tận dụng qurey của sql để làm thôi. Thank to all
paulsteigel > 12-09-13, 10:16 AM
INSERT INTO test1 ( SoHD, LoaiHD, NgayNhan, TenKhachHang, MST, MatHang, GiaChuaThue, ThueSuat,
Thue, GhiChu )
SELECT Journal_Import.F21, Journal_Import.F30, Journal_Import.F22, Journal_Import.F23, Journal_Import.F24,
Journal_Import.F25, Journal_Import.F26, Journal_Import.F27, Journal_Import.F28, Journal_Import.F29
FROM Journal_Import
WHERE (((Journal_Import.F21)>0) AND ((Journal_Import.F30)>0) AND ((Exists (SELECT SoHD
FROM test1
WHERE test1.SoHD = Journal_Import.F21 AND test1.LoaiHD = Journal_Import.F30))=False));
INSERT INTO test1 ( SoHD, LoaiHD, NgayNhan, TenKhachHang, MST, MatHang, GiaChuaThue, ThueSuat,
Thue, GhiChu )
SELECT Journal_Import.F21, Journal_Import.F30, Journal_Import.F22, Journal_Import.F23, Journal_Import.F24,
Journal_Import.F25, Journal_Import.F26, Journal_Import.F27, Journal_Import.F28, Journal_Import.F29
FROM Journal_Import
WHERE (((Journal_Import.F21)>0) AND ((Journal_Import.F30)>0) AND (Journal_Import.F21 NOT IN (SELECT
SoHD FROM test1
WHERE test1.SoHD = Journal_Import.F21 AND test1.LoaiHD = Journal_Import.F30)));
SELECT a.F21 as SoHD, a.F30 as LoaiHD, a.F22 as NgayNhan, a.F23 as TenKhachHang, a.F24 as MST,
a.F25 as MatHang, a.F26 as GiaChuaThue, a.F27 as ThueSuat, a.F28 as Thue, a.F29 as GhiChu INTO tmpTbl1
FROM Journal_Import AS a
WHERE (((a.F21)>0) AND ((a.F30)>0));
SELECT a.SoHD, a.LoaiHD, a.NgayNhan, a.TenKhachHang, a.MST, a.MatHang, a.GiaChuaThue,
a.ThueSuat, a.Thue, a.GhiChu
FROM tmpTbl1 AS a LEFT JOIN test1 AS b ON a.[LoaiHD] = b.[LoaiHD]
WHERE (((b.LoaiHD) Is Null));
Shigeshi Hitoshi > 12-09-13, 02:10 PM
Shigeshi Hitoshi > 12-09-13, 02:47 PM
paulsteigel > 13-09-13, 10:00 AM
SELECT a.F21 AS SoHD, a.F30 AS LoaiHD, a.F22 AS NgayNhan, a.F23 AS TenKhachHang, a.F24 AS MST, a.F25 AS MatHang,
a.F26 AS GiaChuaThue, a.F27 AS ThueSuat, a.F28 AS Thue, a.F29 AS GhiChu INTO tmpTbl1
FROM Journal_Import AS a
WHERE (((a.F21) Is Not Null) AND ((a.F30) Is Not Null));
WHERE ((([a].[F21] And [a].[F30] And [a].[F22] And [a].[F23] And [a].[F24] And [a].[F25] And [a].[F26] And [a].[F27] And [a].[F28] And [a].[F29]) Is Not Null));
Shigeshi Hitoshi > 13-09-13, 12:46 PM
Shigeshi Hitoshi > 13-09-13, 02:23 PM