Careful with table name alias

  • Comments posted to this topic are about the item Careful with table name alias

    ----------------------------------------------------------------------------------------------------------------------------------------------------
    Roshan Joe

    Jeff Moden -Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • Very interesting...

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • I think the results on this should be expected. I think the query was written interestingly enough.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • It is very interesting. However, am still not clear on [flag ='y' ]. Can someone tell me what is this flag. I didnt get any content in BOL.

    thanks


    erajendar

  • Good question, although not that hard (for 2 points).

    erajendar (5/13/2010)


    It is very interesting. However, am still not clear on [flag ='y' ]. Can someone tell me what is this flag. I didnt get any content in BOL.

    The flag isn't actually there. Since it is contained in brackets, it is just an alias name for the table.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • very interesting, this table alias in select clause got me puzzled for a moment. 🙂

  • fine, but correct is 'Careful with '

    (no rtrim and lower used)

  • Really good question, create confusion in mind for the "=" sign used in alias.

  • I learnt another thing, thanks to the Question of the day. 🙂

  • if flag is alias then can we use next statement like

    select [flag='y'].some_data from [where]?

  • saranya.megalai (5/14/2010)


    if flag is alias then can we use next statement like

    select [flag='y'].some_data from [where]?

    No 🙂

    I haven't tested it, but the following should work:

    select [flag='y'].some_data from [where] [flag='y']

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Really interesting and good question. :Wow:

    KSB
    -----------------------------
    Thousands of candles can be lit from a single candle, and the life of the candle will not be shortened. Knowledge and happiness never decreases by being shared.” - Buddha

  • Really its a good question about square brackets.we can use square brackets efficiently at any time.

    Malleswarareddy
    I.T.Analyst
    MCITP(70-451)

  • Interesting question, it was the alias that almost caught me out. Have seen plenty of attributes named as reserved words in the past which has caused a few issues unless squared brackets were used. Thinking back I had an interview question once where there was a table called ORDER and the question was what would happen.

    Hope this helps,
    Rich

    [p]
    [/p]

  • saranya.megalai (5/14/2010)


    if flag is alias then can we use next statement like

    select [flag='y'].some_data from [where]?

    Yes it would look like:

    Select [flag ='y' ].some_data from [where] [flag ='y' ]

Viewing 15 posts - 1 through 15 (of 44 total)

You must be logged in to reply to this topic. Login to reply