Howdy
You appear to have a comma after the FROM clause and before the WHERE clause, so try removing it:
SELECT JOBCST_HDR.ID_JOB_ODBC, JOBCST_HDR.NAME_CUST,
(SELECT TOP 1 SHPORD_HDR.ID_ITEM_PAR
FROM PUBLIC.SHPORD_HDR SHPORD_HDR
WHERE JOBCST_HDR.ID_JOB_ODBC=SUBSTRING(SHPORD_HDR.ID_SO_ODBC,4,6))
FROM PUBLIC.JOBCST_HDR JOBCST_HDR
WHERE JOBCST_HDR.STAT_JOB='O'
Are you targeting SQL Server with the code (as Substring isn't supported in the Access driver AFAIK)? I don't know if SQL Server supports SELECT TOP 1 syntax so this may be another source of the problem.
Richard
Bookmarks