Syntax Error (Missing Operator) in Query Expression in Ms Access

MS-Access : Syntax error (missing operator) in query expression

I think your quotes are wrong. MS Access uses double quotes for strings:

IIf([Employee List].[Employee Type] = "Employee",
Format([Employee List].[Date of Birth], "dd/mm/yyyy"),
"01/01/1910"
) AS DateofBirth

Also, the column alias needs to be a single word or be escaped.

syntax error (missing operator) in query expression - VBA and Access

No two SQL dialects are exactly the same for exact transferability. Simply, MariaDB's SQL will not perfectly align to MS Access' SQL similar to running same query from Oracle to Postgres, MySQL to SQL Server, Sybase to DB2... There will need to be some translation.

Specifically:

  • DATE_FORMAT is not an available function in MS Access. Instead use FORMAT with appropriate format pattern which does not use %.

  • More than one JOIN require parentheses wrapping in MS Access. However, your mix of RIGHT JOIN and LEFT JOIN may require nested joining.

    (Admittedly, this is a frustrating requirement for new Access users to build complex queries with Query Designer and not SQL. I raised this suggested change among others to Access' SQL dialect.)

  • Fortunately, backticks are supported in MS Access though square brackets, [...], are the more popular form to escape identifiers with special characters or keywords.

Consider following adjustment:

SELECT e.codigo AS `Código`,
e.razao_social AS `Razão Social`,
e.grupo AS `Grupo`,
e.tributacao AS `Tributação`,
e.sistema AS `Sistema`,
r.nome AS `Responsável`,
FORMAT(t.competencia, 'mm/yyyy') AS `Competência`,
s.nome AS `Status`,
c.nome AS `Tipo Conferência`
FROM ((((empresa AS e
RIGHT JOIN tarefa AS t ON t.id_empresa = e.id_empresa)
LEFT JOIN responsavel AS r ON t.id_responsavel = r.id_responsavel)
LEFT JOIN status AS s ON t.id_status = s.id_status)
LEFT JOIN conferencia AS c ON t.id_conferencia = c.id_conferencia)
WHERE c.nome = 'Encerramento Contábil'
ORDER BY `Competencia`;

Syntax error (missing operator) in query expression c# (access database)

You have multiple tables you are joining across but have not specified which table your WHERE clause is looking up on.

string query = "Select e.Denumire_Ech, e.Descriere_Ech, e.UnitateMasura, e.Pret_Vanzare, o.Cantitate_EchOf From ECHIPAMENTE e INNER JOIN OFERTE o ON e.Cod_Echipament = o.Cod_Echipament INNER JOIN CONTRACTE c ON c.Cod_Oferta = o.Cod_Oferta INNER JOIN FACTURI f ON f.Nr_Contract = c.Nr_Contract WHERE c.Nr_Contract='" + CB_Contract.Text + "'";

Also you should watch out for SQL injection and unusual characters in the CB_Contract.Text For example if there is a ' character then the sql will fail.



Related Topics



Leave a reply



Submit