我目前将此视图编写为以下脚本。问题是我找不到任何以65开头的收据号,但可以看到那些有20个。这可能是什么问题。
SELECT dbo.Bio_Data.Salutation, dbo.Bio_Data.FirstName, dbo.Bio_Data.MiddleInitial, dbo.Bio_Data.LastName, dbo.Bio_Data.birthPlace, CONVERT(varchar(10),
dbo.Bio_Data.BirthDate, 103) AS DOB, dbo.Bio_Data.Occupation, dbo.Bio_Data.Nationality, dbo.Bio_Data.Address, dbo.Bio_Data.PermanentAddress,
dbo.Bio_Data.photo, dbo.Bio_Data.gender, dbo.[Document].ValidityFrom, CONVERT(varchar(10), dbo.[Document].ExpirationDate, 103) AS ExpDate, dbo.Bio_Data.NIN,
dbo.Bio_Data.fingerprintImage, dbo.Bio_Data.NextOfKin, dbo.Bio_Data.NationalityAtBirth, dbo.Bio_Data.MaritalStatus, dbo.Bio_Data.receiptNo,
dbo.Bio_Data.NextOfKinAddress, dbo.[Document].DocumentTypeID, dbo.Bio_Data.SigIDNumber, dbo.Bio_Data.BloodType, dbo.[Document].DataEntryCompleted,
dbo.[Document].CardPrinted, dbo.[Document].CardNumber, dbo.[Document].CPVerified, dbo.[Document].CPVerifiedBy, dbo.[Document].DEVerified,
dbo.[Document].DatePrinted, dbo.[Document].DateModified
FROM dbo.Bio_Data INNER JOIN
dbo.[Document] ON dbo.Bio_Data.NIN = dbo.[Document].DocumentHolderNIN AND dbo.Bio_Data.receiptNo = dbo.[Document].ReceiptNo
WHERE (dbo.Bio_Data.ApprovalStatus = 'Approved') AND (dbo.Bio_Data.photo IS NOT NULL) AND (dbo.Bio_Data.fingerprintImage IS NOT NULL) AND
(dbo.[Document].CardPrinted IS NULL) AND (dbo.[Document].ReceiptNo LIKE '20%' OR
dbo.[Document].ReceiptNo LIKE '65' OR
dbo.[Document].ReceiptNo LIKE '51%' OR
dbo.[Document].ReceiptNo LIKE '45%')
答案 0 :(得分:3)
dbo.[Document].ReceiptNo LIKE '65'
应该是
dbo.[Document].ReceiptNo LIKE '65%'
如果没有%
通配符,则65
之后不会匹配任何内容。因此,它会找到 65
的记录,而不是以 65
开头的记录。