22,298
社区成员
发帖
与我相关
我的任务
分享
不好意思啊,没格式化;
vCu_Customer是一个视图,如下:
SELECT dbo.Cu_Customer.PID, dbo.Cu_Customer.CustCode, dbo.Cu_Customer.CustName,
dbo.Cu_Customer.CustOtherName, dbo.Cu_Customer.Tel, dbo.Cu_Customer.Fax,
dbo.Cu_Customer.Industry, dbo.Cu_Customer.XinYong, dbo.CU_Contact.ContName,
dbo.CU_Contact.PID AS ContID, dbo.CU_Contact.Dept, dbo.CU_Contact.Job,
dbo.CU_Contact.FamilyTel, dbo.CU_Contact.WorkTel, dbo.CU_Contact.MobileTel,
FROM dbo.Cu_Customer INNER JOIN
dbo.CU_Contact ON dbo.Cu_Customer.PID = dbo.CU_Contact.CustID
WHERE (dbo.CU_Contact.Base = 1)
SELECT TOP 100 pid,
lastcontacttextnew,
remark,
createdate,
custcode,
custname
FROM vcu_customer
LEFT JOIN sy_share
ON (vcu_customer.pid = sharepid
AND sharetablename = 'Cu_Customer'
AND shareuserid = 246)
WHERE vcu_customer.pid NOT IN (SELECT TOP 0 vcu_customer.pid -- 这里怎么回事啊,存心折腾 SQL 是吧!
FROM vcu_customer
LEFT JOIN sy_share
ON (vcu_customer.pid = sharepid
AND sharetablename = 'Cu_Customer'
AND shareuserid = 246)
WHERE ((1 = 1)
AND (custpublictype IS NULL
OR custpublictype = 0)
AND (issaleok = 0
OR issaleok IS NULL))
AND (owner = 246
OR share = 1
OR shareuserid = 246))
AND ((1 = 1)
AND (custpublictype IS NULL
OR custpublictype = 0)
AND (issaleok = 0
OR issaleok IS NULL))
AND (owner = 246
OR share = 1
OR shareuserid = 246)
AND (custpublictype = 0
OR custpublictype IS NULL)