Share via

Syntax error in FROM clause

Anonymous
2013-04-22T18:58:21+00:00

The following SQL works just fine as the rowsource for a list box in an adp. It also works in SQL Server (with the "dbo_" part removed from the table names). However, it doesn't work in the accdb I'm converting to and gives me a "Syntax error in FROM clause" error.

select EID as [ID], s.Definition as [Site], fname + ' ' + lname as [Name]

from dbo_lk_ID as m join dbo_lk_site as s on m.site = s.site join dbo_RAND as r on m.EID = r.ID

where len(ID) >= 8

order by Len(EID) desc, EID desc

I would appreciate your help.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2013-04-22T19:09:36+00:00

Try this with INNER and parenthesis --

select EID as [ID], s.Definition as [Site], fname + ' ' + lname as [Name]

from (dbo_lk_ID as m INNER join dbo_lk_site as s on m.site = s.site) INNER join dbo_RAND as r on m.EID = r.ID

where len(ID) >= 8

order by Len(EID) desc, EID desc;

Was this answer helpful?

0 comments No comments

5 additional answers

Sort by: Most helpful
  1. Anonymous
    2013-04-22T19:47:34+00:00

    With an ACCDB you have to use JET syntax (unless you check the option to use ANSI SQL)

    Bill, that sounds interesting: How exactly do you check the option to use ANSI SQL? I looked and couldn't find it anywhere.

    Thanks.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2013-04-22T19:38:01+00:00

    Thanks everyone! I first tried changing the join to an inner join but I got a "syntax error (missing operator) in query expression" error. I then added the parentheses where Karl indicated and it worked beautifully.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2013-04-22T19:09:15+00:00

    With an ACCDB you have to use JET syntax (unless you check the option to use ANSI SQL)

    SELECT   EID AS [ID]

    , s.Definition AS [Site]

    , fname & ' ' & lname AS [Name]

    FROM     dbo_lk_ID AS m

    INNER JOIN dbo_lk_site AS s

    ON       m.site = s.site

    INNER JOIN dbo_RAND AS r

    ON       m.EID = r.ID

    WHERE    LEN(ID) >= 8

    ORDER BY LEN(EID) DESC

    , EID DESC

    You don't have to format it the way I did, but the syntax should work.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2013-04-22T19:07:47+00:00

    Access uses INNER JOIN instead of just JOIN

    Was this answer helpful?

    0 comments No comments