Results 1 to 8 of 8

Thread: Access doesn't like this query

  1. #1

    Thread Starter
    Hyperactive Member greg_quinn's Avatar
    Join Date
    Nov 2002
    Location
    South Africa
    Posts
    366

    Unhappy Access doesn't like this query

    I have this query, but MS Access 2000 doesn't seem to like the second INNER JOIN, it tells me 'Synax, missing operator in query expression'

    Is my query incorrect, or does Access not handle multiple joins? If so, how could I rewrite my query?

    SELECT sms_contacts.ContactName + ',' + sms_outbox.Message
    FROM sms_contacts
    INNER JOIN sms_recipients ON sms_contacts.ContactID = sms_recipients.ContactID
    INNER JOIN sms_outbox ON sms_recipients.smsID = sms_outbox.smsoutboxID

  2. #2
    Hyperactive Member Lil Ms Squirrel's Avatar
    Join Date
    Nov 2004
    Location
    planet squirrel
    Posts
    494
    I recreated your table structure and ran it through the Access query designer which gave me the same error.

    However, when I switched to design view and created the joins visually, Access provided me with this SQL string:

    Code:
    SELECT sms_contacts.ContactName+','+sms_outbox.Message AS Expr1
    FROM (sms_contacts INNER JOIN sms_recipients ON sms_contacts.ContactID = sms_recipients.ContactID) INNER JOIN sms_outbox ON sms_recipients.SMSID = sms_outbox.smsoutboxid
    Access has put your joins in in a different order. I don't have time to check this out in SQL Query Analyser, but it should help you out with Access in the meantime.

    If I can suss it out elsewere then I'll give you another shout.

    Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind.
    Dr. Seuss

  3. #3
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    Access requires the parentheses around the join expressions as in Lil Ms' code. In SQL Server, you can get away without the parens, but Access is pickier.
    "It's cold gin time again ..."

    Check out my website here.

  4. #4

    Thread Starter
    Hyperactive Member greg_quinn's Avatar
    Join Date
    Nov 2002
    Location
    South Africa
    Posts
    366
    Thanks people. One has to wonder why can't MS just make its access interpreter in the same style as SQL Servers? I mean for sure, take out some functionality, but why change the syntax requirements?

  5. #5

    Thread Starter
    Hyperactive Member greg_quinn's Avatar
    Join Date
    Nov 2002
    Location
    South Africa
    Posts
    366
    Bah, now when I finally try this query (on a Sunday night) in Access, it asks me for the ContactID???

    In my actual program, it gives me an error, saying no value given for one or more required parameters..

    I don't see anything wrong with the query...

    Thanks

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    sms_contacts.ContactID and sms_recipients.ContactID exist in both tables
    and are spelled like in your query?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Hyperactive Member greg_quinn's Avatar
    Join Date
    Nov 2002
    Location
    South Africa
    Posts
    366
    sms_contacts.ContactID and sms_recipients.ContactID exist in both tables and are spelled like in your query?
    I'm not sure what you are asking, but yes, contactID field exists in both tables, my query is...

    SELECT sms_contacts.ContactName+','+sms_outbox.Message AS Expr1
    FROM (sms_contacts INNER JOIN sms_recipients ON sms_contacts.ContactID = sms_recipients.ContactID) INNER JOIN sms_outbox ON sms_recipients.SMSID = sms_outbox.smsoutboxid

  8. #8
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263
    Originally posted by greg_quinn
    Thanks people. One has to wonder why can't MS just make its access interpreter in the same style as SQL Servers? I mean for sure, take out some functionality, but why change the syntax requirements?
    ACCESS is MS home-grown attempt at SQL. MS SQL SERVER 2000 is a product developed by SYBASE - purchased by MS - and now taking over the SQL enterprise market (just don't ask Larry Elison what he thinks about that)

Posting Permissions

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



Click Here to Expand Forum to Full Width