?
Solved

Concatenation in an SQL Statement

Posted on 2003-02-24
6
Medium Priority
?
1,189 Views
Last Modified: 2007-12-19
Hi,

does anyone know how to concatenate two fields in an SQL statement in Access.

in standard SQL this would look like:

select * FROM tbCalls WHERE 'Fred Bloggs' = tbCalls.Firstname || tbCalls.Surname;

Access doesn't like the || in the statement, is there a replacement for that would work.

Thanks Jon
0
Comment
Question by:jonky
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Expert Comment

by:hessmac
ID: 8012485
you can concatenate alphanumeric and numeric values with the & operator.

ps: your statement will not work.
    check the where clause from your select statement !!




0
 
LVL 4

Expert Comment

by:bistrica
ID: 8012533
select *, (tbCalls.Firstname & " " & tbCalls.Surname) AS full_name FROM tbCalls WHERE full_name = 'Fred Bloggs';
0
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 200 total points
ID: 8013053
You can't use the field alias in the WHERE clause, so you'll need to use something like:

SELECT * FROM tbCalls WHERE Firstname & " " & Surname = "Fred Bloggs"
0
 

Expert Comment

by:hessmac
ID: 8021069
Copy & Past into the msaccess sql-sheet of a new query.
Change the Table/Fieldnames to your Table/Fieldnames.  
Option 1:

SELECT [Table3].[Firstname] & " " & [Table3].[Lastname] AS Expr1
FROM Table3
WHERE ((([Table3].[Firstname] & " " & [Table3].[Lastname])="Fred Bloggs"));


Option 2 with the "LIKE"-option:

SELECT [Table3].[Firstname] & " " & [Table3].[Lastname] AS Expr1
FROM Table3
WHERE ((([Table3].[Firstname] & " " & [Table3].[Lastname]) Like "fREd bloGgs*"));


Option 3 is the same as option 2 except for the extra field we display:

SELECT [Table3].[Firstname] & " " & [Table3].[Lastname] AS Name, [Table3].[ID]
FROM Table3
WHERE ((([Table3].[Firstname] & " " & [Table3].[Lastname]) Like "fREd bloGgs*"));

0
 
LVL 18

Expert Comment

by:1William
ID: 8734708
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept question, points to shanesuebsahakarn
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
1William
EE Cleanup Volunteer
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question