Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Sql!

Options
  • 26-02-2008 4:43pm
    #1
    Closed Accounts Posts: 5,240 ✭✭✭


    SELECT top 500 e.EventTypeID, e.EventTime, t.Description, e.Description, t.IsError, e.PeopleID, e.OperatorID,e.EventID
    FROM Events e
    LEFT OUTER JOIN eventtypes t on e.EventTypeID = t.EventTypeID
    WHERE (e.eventtypeid > 3000) and (e.eventtypeid < 4000) and (e.PeopleID <> '0')
    ORDER BY e.eventid desc

    I was given this sql statement as an example to aid in a project i am busy with. I understand sql and can read this statement, but i don't understand the e. and t. notation that he is using?
    Could anyone explain the meaning of the syntax.

    Cheers
    Endo


Comments

  • Closed Accounts Posts: 162 ✭✭totoal


    No expert but i think it's just a shortcut to shorten table names. 'Events' is shortened to 'e'
    and 'eventtypes' is shortened to 't'


  • Closed Accounts Posts: 5,240 ✭✭✭Endurance Man


    Yup, correcto totoal, thanks :D.
    Let the learning continue.


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    The statement allows you to specify shorthand for table names so that you don't have to type them every time. A heavily normalised database may have huge table names, so it help readability and typability to shorten them.

    So say I have the above table "Events" and "Eventtypes" and I want two columns from events and two from eventtypes

    Without shorthand, I would have to type

    select events.col1, events.col2, eventtypes.col1, eventtypes.col2 from events, eventypes

    Or, I could give the table names a shorthand by just writing the shorthand beside the table name in the FROM portion of the statement,

    so

    select e.col1, e.col2, t.col1, t.col2 from events e, eventypes t


  • Closed Accounts Posts: 5,240 ✭✭✭Endurance Man


    Cheers seamus, does make sense, I got the statement working now, think thats my que to head home ^^.


Advertisement