在连接两个表时,我对如何构建 SQL 查询感到困惑,以便以后可以将它们绑定到 gridview。
基本上我有两张桌子,
tablename: family
__________________________
|Status |lastName|firstName|
|-------|--------|---------|
|1 |11 |111 |
|2 |22 |222 |
|3 |33 |333 |
''''''''''''''''''''''''''''
+
tablename: familyStatus
_____________________
|id | Notes |
|----------|----------|
|1 | 1111 |
|2 | 2222 |
|3 | 3333 |
'''''''''''''''''''''''
=
Joined-tables: family+familyStatus [this is what i want]
____________________________
|firstName | lastName |Notes |
|----------|----------|------|
|111 | 11 |1111 |
|222 | 22 |2222 |
|333 | 33 |3333 |
''''''''''''''''''''''''''''''
您在这里看到的是表族的状态和familyStatus的id是相同的键,状态和id 将隐藏在gridview 上。
Lets just assume for now that this is how i get the family table.
SELECT Status, firstName, lastName
FROM family
WHERE firstName= @fN
AND lastName = @lN
我需要在此处添加什么以便家庭表中的注释也被加入?