Skip to content
Advertisement

What does the following SQL query do?

The drawing logs at that the company I work for use are written in MS Access VBA. The original code was written 15+ years ago by someone else, and we’re now running into errors with the reporting functionality that we can’t find a solution for.

The query I’m having an issue with is the following:

Select Case Me.frameBaseType
    Case 1  'All drawings
        strFROM = "FROM (Company RIGHT JOIN Drawings ON Company.ID = Drawings.Company) LEFT JOIN Revisions ON Drawings.ID = Revisions.DwgID "

    Case 2  'Most recent revision
        strFROM = "FROM Company RIGHT JOIN ((Drawings INNER JOIN [For Report - Group Revision] ON Drawings.ID = "
        strFROM = strFROM & "[For Report - Group Revision].CbnDwgID) INNER JOIN Revisions ON (Drawings.ID = Revisions.DwgID) AND "
        strFROM = strFROM & "([For Report - Group Revision].RecentRevision = Revisions.ESIRevision)"
        strFROM = strFROM & " AND ([For Report - Group Revision].RevDate = Revisions.RevDate)"
        strFROM = strFROM & ") ON Company.ID = Drawings.Company "

    Case 3  'Due or late in routing
        strFROM = "FROM (Company RIGHT JOIN Drawings ON Company.ID = Drawings.Company) LEFT JOIN Revisions ON Drawings.ID = Revisions.DwgID "
        strWHERElate = "WHERE (((Revisions.Due)=1 Or (Revisions.Due)=2)) "
        strWHERE = strWHERElate

    Case 4  'Due or late from Vendor
        strFROM = "FROM (Company RIGHT JOIN Drawings ON Company.ID = Drawings.Company) LEFT JOIN Revisions ON Drawings.ID = Revisions.DwgID "
        strWHERElate = "WHERE (((Revisions.Due)=3 Or (Revisions.Due)=4)) "
        strWHERE = strWHERElate
End Select

Does anyone know what the notation [For Report - Group Revision] means in a SQL query?

Advertisement

Answer

Square brackets are used for quoting entity names. Standard SQL uses ".

In this context, [For Report - Group Revision] being to the left of the period refers to a table or table-like object such as a view, report or other data source.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement