Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Sql!

  • 26-02-2008 04: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, Registered Users 2 Posts: 68,173 ✭✭✭✭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