Is this query correct ?

  • spectra

    Hall of Fame

    Points: 3893

    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 ?

  • Thom A

    SSC Guru

    Points: 98135

    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.

  • Jonathan AC Roberts

    SSCoach

    Points: 16499

    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.

  • spectra

    Hall of Fame

    Points: 3893

    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 ?

  • spectra

    Hall of Fame

    Points: 3893

    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 ?

  • Jeff Moden

    SSC Guru

    Points: 993788

    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.
    "If you think its expensive to hire a professional to do the job, wait until you hire an amateur."--Red Adair
    "Change is inevitable... change for the better is not."
    When you put the right degree of spin on it, the number 3|8 is also a glyph that describes the nature of a DBAs job. πŸ˜‰

    Helpful Links:
    How to post code problems

  • Thom A

    SSC Guru

    Points: 98135

    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.

  • drew.allen

    SSC Guru

    Points: 76436

    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

  • Jonathan AC Roberts

    SSCoach

    Points: 16499

    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.

  • ChrisM@Work

    SSC Guru

    Points: 186038

    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.

    [font="Arial"]β€œWrite the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw[/font]


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

  • Thom A

    SSC Guru

    Points: 98135

    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.

  • Brandie Tarvin

    SSC Guru

    Points: 172509

    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.

  • Jonathan AC Roberts

    SSCoach

    Points: 16499

    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#.

  • Jeff Moden

    SSC Guru

    Points: 993788

    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.
    "If you think its expensive to hire a professional to do the job, wait until you hire an amateur."--Red Adair
    "Change is inevitable... change for the better is not."
    When you put the right degree of spin on it, the number 3|8 is also a glyph that describes the nature of a DBAs job. πŸ˜‰

    Helpful Links:
    How to post code problems

  • frederico_fonseca

    SSChampion

    Points: 14041

    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 16 total)

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