我需要计算GID上匹配的记录数
Dim iSubscriptionCount
SQLCommand = "SELECT COUNT(*) AS Counter FROM Directories.GID, ClientSubscriptons.DirectoryGID FROM Directories, ClientSubscriptons WHERE Directories.GID = ClientSubscriptons.DirectoryGID;"
rsTemp.Open SQLCommand, objConn, adOpenStatic, adLockReadOnly
iSubscriptionCount = rsTemp("Counter")
rsTemp.Close
if iSubscriptionCount <= 0 then
%><a href="AddDirectory.asp?PGID=<% = rsDirectory("GID") %>"><% = GetIcon("Add", "Add Sub Directory", 25, True) %></a><%
我需要计算GID上匹配的记录数
答案 0 :(得分:0)
你有两个条款...... sql应该读...
SELECT COUNT(*) AS Counter, Directories.GID, ClientSubscriptions.DirectoryGID
FROM Directories, ClientSubscriptions
WHERE Directories.GID = ClientSubscriptions.DirectoryGID
您可能还需要
GROUP BY Directories.GID, ClientSubscriptions.DirectoryGID;
最后
答案 1 :(得分:0)
我不太了解¿Visual Basic?但是你在同一个句子中有两个'FROM'。不会
SELECT COUNT(*) AS Counter
FROM Directories, ClientSubscriptons
WHERE Directories.GID = ClientSubscriptons.DirectoryGID
解决问题?
答案 2 :(得分:0)
您的问题不是很清楚......如果您只想计算目录和客户订阅之间的匹配,您必须执行这样的JOIN
SELECT COUNT(*) AS Counter FROM
Directories join ClientSubscriptons
on Directories.GID = ClientSubscriptons.DirectoryGID
特许经营部分完全模糊不清......你想在两个表上匹配franchiseGID吗?那么你的查询应该是这样的
SELECT COUNT(*) AS Counter FROM
Directories join ClientSubscriptons
on Directories.GID = ClientSubscriptons.DirectoryGID
and Directories.FranchiseGID = ClientSubscriptons.FranchiseGID
要获得更准确的答案,请更清楚