注册 登录
编程论坛 SQL Server论坛

SQL语句问题

wube 发布于 2017-05-08 13:17, 1742 次点击
底下SQL查询语法中的 as A 和 as B 是什么意思?
为什么A和B不用定义就能用?

程序代码:
    Private Sub LoadFileList(ByVal strSubjectNo As String, ByVal strSubFolderNo As String)
        Dim mySQL As String
        mySQL = "SELECT ROW_NUMBER() OVER (" & hdfFileListOrderBy.Value & ") AS RowNo, A.*, B.EmployeeName AS ReviserName FROM tblFileList AS A "
        mySQL += "LEFT OUTER JOIN tblMstEmployee AS B ON A.ReviserNo = B.EmployeeNo "
        mySQL += "WHERE A.SubjectNo = '" & strSubjectNo & "' AND A.SubFolderNo = " & strSubFolderNo
        If lblFileMgnTitleChi.Text <> "内部下载" Then
            mySQL += "AND A.ShowInPublic = 'Y'"
        End If
        Try
            Using mySqlDS As SqlDataSource = New SqlDataSource
                mySqlDS.ProviderName = strDbType
                mySqlDS.ConnectionString = WebConfigurationManager.ConnectionStrings(strCnnType & "DbBTA").ConnectionString
                mySqlDS.SelectCommand = mySQL
                mySqlDS.DataSourceMode = SqlDataSourceMode.DataSet
                Dim my_args As New DataSourceSelectArguments
                Dim my_DV As Data.DataView = mySqlDS.Select(my_args)
                lvFileList.DataSource = my_DV
                lvFileList.DataBind()
            End Using
        Catch ex As Exception
            Dim strErr As String = "●●● 程式错误讯息如下 ●●●" & "\n\n" & Replace(Replace(Replace(Replace(Trim(ex.ToString()), Chr(10), ""), Chr(13), ""), "\", "\\"), "'", "\'")
            ScriptManager.RegisterStartupScript(Me, Me.GetType(), "alert", "alert('" & strErr & "');", True)
        End Try
    End Sub



2 回复
#2
mywisdom882017-05-09 21:37
是别名,为了方便书写
select a.编号,a.姓名,b.成绩 from 深圳市中学生信息表 as a
left join 深圳市中学生成绩表 as b on a.编号=b.编号
如果不用别名,那就这个样了

select 深圳市中学生信息表.编号,深圳市中学生信息表.姓名,深圳市中学生成绩表.成绩 from 深圳市中学生信息表
left join 深圳市中学生成绩表 on 深圳市中学生信息表.编号=深圳市中学生成绩表.编号
是不是上面的方便



#3
wube2017-05-10 11:05
原来如此

1