Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    Join Date
    May 2010
    Posts
    13

    Unanswered: Inner Join Question

    The answer to this question iss likely obvious, but it seems to be the obvious ones that ellude me the most.

    I am trying to join two tables, customers and billing groups, so that the billing group description appears in the result. Here is the code.

    select C.custid, C.localname, C.billingcycle, B.Description, C.lastordered
    from tblBillingCycles AS B
    inner join tblCustomer AS C ON B.billingcycle = C.billingcycle

    Not sure what I'm doing wrong. Any guidance would be appreciated.

    Thanks,
    Dan

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by dwdwone View Post
    Not sure what I'm doing wrong.
    nothing
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Yup. Other than the aggravating use of gratuitous and confusing table aliases, it looks fine to me.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by blindman View Post
    ... the aggravating use of gratuitous and confusing table aliases
    stop flogging this dead horse

    you're, ahem, whistling into the wind
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    flogging f
    dead d
    horsie h


    STOP f
    THIS d h

    I have been convinced by blindman on this one.

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by pootle flump View Post
    STOP f
    THIS d h
    Message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'STOP f'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  7. #7
    Join Date
    Dec 2007
    Location
    Richmond, VA
    Posts
    1,328
    Provided Answers: 5
    Dan,
    I think the better question is why do you think this is wrong?
    I would guess that you are getting multiple rows back for each customer and therefore you think you have done something wrong. I would be willing to bet that you are getting a row for each billing cycle that a user has been through.
    Dave

  8. #8
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by r937 View Post
    Message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'STOP f'
    We're in the Microsoft SQL Server topic here Rudy
    George
    Home | Blog

  9. #9
    Join Date
    May 2010
    Posts
    13
    Well, as far as the naming conventions, it's not my db. I just sort of inherited the responsibility of getting the data out since I'm the only one who knows SQL at my company. Cut my teeth on RBase back in the late 1990's and i's now come back to haunt me!

    The system returns no data when I run the query. I get a popup box that says Unexpected Error.

  10. #10
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by dwdwone View Post
    I get a popup box that says Unexpected Error.
    Well none of us would have expected that.
    The aliases blindman refers to are the B and C names, but it is irrelevant to your problem.

    What is the client?
    Last edited by pootle flump; 06-02-10 at 13:30.

  11. #11
    Join Date
    May 2010
    Posts
    13
    The client is MS SQL Server.

  12. #12
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    That's the server. What's the client? E.g. SQL Server Management Studio, Query Analyser, Access etc.

  13. #13
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by gvee View Post
    We're in the Microsoft SQL Server topic here Rudy
    oh gosh i should have included a smiley, because you have surely missed the intended sarcasm in my post
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  14. #14
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    SQL Server gives you an error that simply says "Unexpected Error"???

    I don't think so....something else is generating that. What are you using to run the query?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  15. #15
    Join Date
    May 2010
    Posts
    13
    I believe it uses C and VB6. I've got a call out to them to verify.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •