简体   繁体   中英

Syntax to concatenate two columns

I want to concatenate two fields of my Access 2007 database.

This is my query:

sql="SELECT CONCAT(COGNOME & ' ' & NOME) AS NOMECOMPLETO FROM clienti WHERE NOMECOMPLETO LIKE '%Rossi Paolo%'" 

But it does not work, what is the syntax error?

MS Access does not look like other SQL dialects. This should be closer to what you want:

SELECT (COGNOME & " " & NOME) AS NOMECOMPLETO
FROM clienti
WHERE (COGNOME & " " & NOME) LIKE "*Rossi Paolo*";

Changes:

  • There is no CONCAT() .
  • & is used for string concatentation.
  • Double quotes are used for strings.
  • The wildcard for LIKE is * .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM