Is this query correct ?

  • I dont understand the red marked part in my book. 

    Is this query correct ?
    book is using live e , live m .  Why its used twice ?

    Could you please explain whats going on here ?

  • When was that book written, the early 90's?  JOIN syntax is almost 30 years old at this stage; if that is the format of query your book is teaching you I'd recommend getting a new (and more recent) one.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • spectra - Monday, October 15, 2018 2:50 AM

    I dont understand the red marked part in my book. 

    Is this query correct ?
    book is using live e , live m .  Why its used twice ?

    Could you please explain whats going on here ?

    The table is referenced twice with two different aliases (e and m).
    The e is for the employee details and the m is for the manager details.

  • Jonathan AC Roberts - Monday, October 15, 2018 6:51 AM

    spectra - Monday, October 15, 2018 2:50 AM

    I dont understand the red marked part in my book. 

    Is this query correct ?
    book is using live e , live m .  Why its used twice ?

    Could you please explain whats going on here ?

    The table is referenced twice with two different aliases (e and m).
    The e is for the employee details and the m is for the manager details.

    its given live m.

    so m is not for manager details.  its for employee details . is not it ?

  • Thom A - Monday, October 15, 2018 6:47 AM

    When was that book written, the early 90's?  JOIN syntax is almost 30 years old at this stage; if that is the format of query your book is teaching you I'd recommend getting a new (and more recent) one.

    Could not get you.
    do you mean that query is wrong ?

    What is the correct version ?

  • Thom A - Monday, October 15, 2018 6:47 AM

    When was that book written, the early 90's?  JOIN syntax is almost 30 years old at this stage; if that is the format of query your book is teaching you I'd recommend getting a new (and more recent) one.

    Heh... maybe not... I've seen worse in some current day books and online articles.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • spectra - Monday, October 15, 2018 7:33 AM

    Thom A - Monday, October 15, 2018 6:47 AM

    When was that book written, the early 90's?  JOIN syntax is almost 30 years old at this stage; if that is the format of query your book is teaching you I'd recommend getting a new (and more recent) one.

    Could not get you.
    do you mean that query is wrong ?

    What is the correct version ?

    It's not that it's "wrong" per say, just that's it uses very old syntax, specifically the ANSI-89 (the 89 stands for the year 1989) JOIN syntax. Aaron Bertrand did an article on it years ago, which you can find here.

    But, that query won't actually run anyway. The FROM clause makes reference to the object manager without an alias, however, the rest of the statement refers the the object managers. managers will return an invalid object name. Also, the line break between managers. and the column name will generate a syntax issue.

    In truth, there's a few problems with that query.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • spectra - Monday, October 15, 2018 7:31 AM

    Jonathan AC Roberts - Monday, October 15, 2018 6:51 AM

    spectra - Monday, October 15, 2018 2:50 AM

    I dont understand the red marked part in my book. 

    Is this query correct ?
    book is using live e , live m .  Why its used twice ?

    Could you please explain whats going on here ?

    The table is referenced twice with two different aliases (e and m).
    The e is for the employee details and the m is for the manager details.

    its given live m.

    so m is not for manager details.  its for employee details . is not it ?

    or this is printing mistake ?  should it be manager m   instead of live m ?

    No, e is for the employee details and m is for the manager details.  There is no alias provided for the manager table.  The manager table only has the name of the employee and their manager.  It does not have the address details.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Thom A - Monday, October 15, 2018 7:43 AM

    spectra - Monday, October 15, 2018 7:33 AM

    Thom A - Monday, October 15, 2018 6:47 AM

    When was that book written, the early 90's?  JOIN syntax is almost 30 years old at this stage; if that is the format of query your book is teaching you I'd recommend getting a new (and more recent) one.

    Could not get you.
    do you mean that query is wrong ?

    What is the correct version ?

    It's not that it's "wrong" per say, just that's it uses very old syntax, specifically the ANSI-89 (the 89 stands for the year 1989) JOIN syntax. Aaron Bertrand did an article on it years ago, which you can find here.

    But, that query won't actually run anyway. The FROM clause makes reference to the object manager without an alias, however, the rest of the statement refers the the object managers. managers will return an invalid object name. Also, the line break between managers. and the column name will generate a syntax issue.

    In truth, there's a few problems with that query.

    You can put a spaces or linefeeds between the dot and the column name. Not that I ever do it but it still works.

  • Jonathan AC Roberts - Monday, October 15, 2018 7:51 AM

    Thom A - Monday, October 15, 2018 7:43 AM

    spectra - Monday, October 15, 2018 7:33 AM

    Thom A - Monday, October 15, 2018 6:47 AM

    When was that book written, the early 90's?  JOIN syntax is almost 30 years old at this stage; if that is the format of query your book is teaching you I'd recommend getting a new (and more recent) one.

    Could not get you.
    do you mean that query is wrong ?

    What is the correct version ?

    It's not that it's "wrong" per say, just that's it uses very old syntax, specifically the ANSI-89 (the 89 stands for the year 1989) JOIN syntax. Aaron Bertrand did an article on it years ago, which you can find here.

    But, that query won't actually run anyway. The FROM clause makes reference to the object manager without an alias, however, the rest of the statement refers the the object managers. managers will return an invalid object name. Also, the line break between managers. and the column name will generate a syntax issue.

    In truth, there's a few problems with that query.

    You can put a spaces or linefeeds between the dot and the column name. Not that I ever do it but it still works.

    Some people do this as part of their "personal formatting preference". It makes the code look very weird and hard to scan. These people should always be re-educated, forcibly if necessary.

    β€œWrite the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • Jonathan AC Roberts - Monday, October 15, 2018 7:51 AM

    You can put a spaces or linefeeds between the dot and the column name. Not that I ever do it but it still works.

    Oh you're right... WHY!? (What have I done to have been introduced to such awful formatting? I can't unsee it now, ahhh!!!)

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Thom A - Monday, October 15, 2018 8:00 AM

    Jonathan AC Roberts - Monday, October 15, 2018 7:51 AM

    You can put a spaces or linefeeds between the dot and the column name. Not that I ever do it but it still works.

    Oh you're right... WHY!? (What have I done to have been introduced to such awful formatting? I can't unsee it now, ahhh!!!)

    Need some brain bleach?

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

  • Brandie Tarvin - Monday, October 15, 2018 11:04 AM

    Thom A - Monday, October 15, 2018 8:00 AM

    Jonathan AC Roberts - Monday, October 15, 2018 7:51 AM

    You can put a spaces or linefeeds between the dot and the column name. Not that I ever do it but it still works.

    Oh you're right... WHY!? (What have I done to have been introduced to such awful formatting? I can't unsee it now, ahhh!!!)

    Need some brain bleach?

    You can do the same thing with dot notation in VB.NET and C#.

  • ChrisM@Work - Monday, October 15, 2018 7:58 AM

    Jonathan AC Roberts - Monday, October 15, 2018 7:51 AM

    Thom A - Monday, October 15, 2018 7:43 AM

    spectra - Monday, October 15, 2018 7:33 AM

    Thom A - Monday, October 15, 2018 6:47 AM

    When was that book written, the early 90's?  JOIN syntax is almost 30 years old at this stage; if that is the format of query your book is teaching you I'd recommend getting a new (and more recent) one.

    Could not get you.
    do you mean that query is wrong ?

    What is the correct version ?

    It's not that it's "wrong" per say, just that's it uses very old syntax, specifically the ANSI-89 (the 89 stands for the year 1989) JOIN syntax. Aaron Bertrand did an article on it years ago, which you can find here.

    But, that query won't actually run anyway. The FROM clause makes reference to the object manager without an alias, however, the rest of the statement refers the the object managers. managers will return an invalid object name. Also, the line break between managers. and the column name will generate a syntax issue.

    In truth, there's a few problems with that query.

    You can put a spaces or linefeeds between the dot and the column name. Not that I ever do it but it still works.

    Some people do this as part of their "personal formatting preference". It makes the code look very weird and hard to scan. These people should always be re-educated, forcibly if necessary.

    Hmmmm.... pork chop opportunity. πŸ˜›

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden - Monday, October 15, 2018 12:20 PM

    ChrisM@Work - Monday, October 15, 2018 7:58 AM

    Jonathan AC Roberts - Monday, October 15, 2018 7:51 AM

    Thom A - Monday, October 15, 2018 7:43 AM

    spectra - Monday, October 15, 2018 7:33 AM

    Thom A - Monday, October 15, 2018 6:47 AM

    When was that book written, the early 90's?  JOIN syntax is almost 30 years old at this stage; if that is the format of query your book is teaching you I'd recommend getting a new (and more recent) one.

    Could not get you.
    do you mean that query is wrong ?

    What is the correct version ?

    It's not that it's "wrong" per say, just that's it uses very old syntax, specifically the ANSI-89 (the 89 stands for the year 1989) JOIN syntax. Aaron Bertrand did an article on it years ago, which you can find here.

    But, that query won't actually run anyway. The FROM clause makes reference to the object manager without an alias, however, the rest of the statement refers the the object managers. managers will return an invalid object name. Also, the line break between managers. and the column name will generate a syntax issue.

    In truth, there's a few problems with that query.

    You can put a spaces or linefeeds between the dot and the column name. Not that I ever do it but it still works.

    Some people do this as part of their "personal formatting preference". It makes the code look very weird and hard to scan. These people should always be re-educated, forcibly if necessary.

    Hmmmm.... pork chop opportunity. πŸ˜›

    ahhhh.. reminds me of a COBOL programmer on a client of mine many years ago.
    In order to keep his position "safe" he named all variables with a combination of 3 or 4 letters/numbers

    AAA1 - invoice number
    AAA2 - Invoice date
    XYZ2 - customer name

    and what each combination meant was only known to himself - and kept away from everyone.
    personal taste taken to extremes.

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

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