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 useFORMAT
with appropriate format pattern which does not use%
.More than one
JOIN
require parentheses wrapping in MS Access. However, your mix ofRIGHT JOIN
andLEFT 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
How to Select Only the Latest Entry in a Table
Ms Access Query with Case Statement
How to Create Text File Using SQL Script with Text "|"
How to Make This Query in SQL Server Compact Edition
Using Tuples to Put More Than 1000 Entries in SQL in Clause
Is There a Function That Takes a Year, Month and Day to Create a Date in Postgresql
Problems with Createdb in Postgres
SQL Inner Join Over Multiple Tables Equal to Where Syntax
How to Combine These Two SQL Statements
Why SQL Server Ignores Vaules in String Concatenation When Order by Clause Specified
How to Write a Query to Extract Individual Changes from Snapshots of Data
How to Get a Value Using SQL in Delphi and Setting the Value to a Variable
Cascade Copy a Row with All Child Rows and Their Child Rows, etc
Split String Oracle into a Single Column and Insert into a Table
Convert Date Range to Individual Days
In SQL, What Does Using Parentheses with an or Mean
Oracle: Similar to Sysdate But Returning Only Time and Only Date