Skip to content

Suggestions on Database aliases when writing SQL statements #263

@singhc00

Description

@singhc00

What are your views on having descriptive table aliases? For example, would you prefer below:

       SELECT 
            notification~qmnum        AS notification_number,
            notification_item~fenum   AS item_number,
            notification_header~equnr AS equiment_number
       FROM qmel AS notification
       INNER JOIN qmih AS notification_header
        ON notification_header~qmnum = notification~qmnum
       INNER JOIN qmfe AS notification_item
        ON notification_item~qmnum = notification_header~qmnum

Or do you prefer to have the database table names as they are short and easy to write in long select statement?

       SELECT
            qmel~qmnum AS notification_number,
            qmfe~fenum AS item_number,
            qmih~equnr AS equiment_number
       FROM qmel
       INNER JOIN qmih 
        ON qmih ~qmnum = qmel~qmnum
       INNER JOIN qmfe
        ON qmfe~qmnum = qmel~qmnum

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions