我有一个包含字母信息的表格。该表记录了可用于发送给客户的不同类型的字母。每个字母都有自己的特定信息字母字段。此表包含letterID,LetterName,LetterNumber和LetterField。
CREATE TABLE #LETTERINFO(
LETTERID INT,
LETTERNAME VARCHAR(MAX),
LETTERNUMBER VARCHAR(MAX),
LETTERFIELD VARCHAR(MAX)
)
INSERT INTO #LETTERINFO (LETTERID, LETTERNAME, LETTERNUMBER, LETTERFIELD) VALUES(101, 'ABC', 'SS_10001-20170101', 'FAXNUMBER')
INSERT INTO #LETTERINFO (LETTERID, LETTERNAME, LETTERNUMBER, LETTERFIELD) VALUES(101, 'ABC', 'SS_10001-20170101', 'PHONENUMBER')
INSERT INTO #LETTERINFO (LETTERID, LETTERNAME, LETTERNUMBER, LETTERFIELD) VALUES(101, 'ABC', 'SS_10001-20170101', 'STATE')
INSERT INTO #LETTERINFO (LETTERID, LETTERNAME, LETTERNUMBER, LETTERFIELD) VALUES(101, 'ABC', 'SS_10001-20170101', 'ZIP')
INSERT INTO #LETTERINFO (LETTERID, LETTERNAME, LETTERNUMBER, LETTERFIELD) VALUES(201, 'EFG', 'HF_10005-20170201', 'ACCOUNTNUMBER')
INSERT INTO #LETTERINFO (LETTERID, LETTERNAME, LETTERNUMBER, LETTERFIELD) VALUES(201, 'EFG', 'HF_10005-20170201', 'BKDATE')
INSERT INTO #LETTERINFO (LETTERID, LETTERNAME, LETTERNUMBER, LETTERFIELD) VALUES(201, 'EFG', 'HF_10005-20170201', 'ADDRESS1')
INSERT INTO #LETTERINFO (LETTERID, LETTERNAME, LETTERNUMBER, LETTERFIELD) VALUES(201, 'EFG', 'HF_10005-20170201', 'BKSTATE')
INSERT INTO #LETTERINFO (LETTERID, LETTERNAME, LETTERNUMBER, LETTERFIELD) VALUES(301, 'XYZ', 'HM_10001-20130109', 'VEMAIL')
INSERT INTO #LETTERINFO (LETTERID, LETTERNAME, LETTERNUMBER, LETTERFIELD) VALUES(301, 'XYZ', 'HM_10001-20130109', 'STATE')
INSERT INTO #LETTERINFO (LETTERID, LETTERNAME, LETTERNUMBER, LETTERFIELD) VALUES(301, 'XYZ', 'HM_10001-20130109', 'VTYPECODE')
INSERT INTO #LETTERINFO (LETTERID, LETTERNAME, LETTERNUMBER, LETTERFIELD) VALUES(301, 'XYZ', 'HM_10001-20130109', 'ADDRESS1')
INSERT INTO #LETTERINFO (LETTERID, LETTERNAME, LETTERNUMBER, LETTERFIELD) VALUES(301, 'XYZ', 'HM_10001-20130109', 'CUSTNAME')
有一个客户端表,其中包含客户端信息,包括上述所有字母字段。 client detail information table
我想要做的是我想从客户端表中选择信息,只查看与特定字母相关的信息。因此,如果我只想查看LetterNumber SS_10001-20170101的信息,我想查看客户表中与该字母相关的所有值
答案 0 :(得分:1)
您似乎只想使用简单的where子句
SELECT * FROM tblClient WHERE LETTERNUMBER = 'SS_10001-20170101'