Using quotes in SQL

  • Thread starter Thread starter Mike Collard
  • Start date Start date
M

Mike Collard

I want to include the following in some SQL for a QueryDef
but can't remember how I should use quotes:-

Select my field from my table where myname = "Smith"

I believe I have to replace the double quotes around Smith
or use single quotes somewhere but can't figure out how.
Sure I saw an article a long time back but can't find it!

Any help appreciated.

Mike C
 
There are a number of ways to do this, Mike. I use the Chr(34) - the
character code for double quotes - because it's easier for me to read:

"Select [my field] from [my table] where [myname] = " & Chr(34) & "Smith" &
Chr(34)

hth,
 
I want to include the following in some SQL for a QueryDef
but can't remember how I should use quotes:-

Select my field from my table where myname = "Smith"

I believe I have to replace the double quotes around Smith
or use single quotes somewhere but can't figure out how.
Sure I saw an article a long time back but can't find it!

Any help appreciated.

Mike C

The criterion for a Text field must be delimited by your choice of '
or ". The doublequote " character is often preferable since people's
names sometimes contain apostrophes - O'Reilly for example. The
apostrophe will be seen as the end of the string if you use ' as a
delimiter.

If you post back with a specific instance of a problem someone should
be able to help!
 
Thanks to John Vinson & Cheryl Fischer

Mike C

-----Original Message-----
There are a number of ways to do this, Mike. I use the Chr(34) - the
character code for double quotes - because it's easier for me to read:

"Select [my field] from [my table] where [myname] = " & Chr(34) & "Smith" &
Chr(34)

hth,

--
Cheryl Fischer
Law/Sys Associates
Houston, TX

I want to include the following in some SQL for a QueryDef
but can't remember how I should use quotes:-

Select my field from my table where myname = "Smith"

I believe I have to replace the double quotes around Smith
or use single quotes somewhere but can't figure out how.
Sure I saw an article a long time back but can't find it!

Any help appreciated.

Mike C


.
 
You're welcome. Good luck with your project.

--
Cheryl Fischer
Law/Sys Associates
Houston, TX

Mike Collard said:
Thanks to John Vinson & Cheryl Fischer

Mike C

-----Original Message-----
There are a number of ways to do this, Mike. I use the Chr(34) - the
character code for double quotes - because it's easier for me to read:

"Select [my field] from [my table] where [myname] = " & Chr(34) & "Smith" &
Chr(34)

hth,

--
Cheryl Fischer
Law/Sys Associates
Houston, TX

I want to include the following in some SQL for a QueryDef
but can't remember how I should use quotes:-

Select my field from my table where myname = "Smith"

I believe I have to replace the double quotes around Smith
or use single quotes somewhere but can't figure out how.
Sure I saw an article a long time back but can't find it!

Any help appreciated.

Mike C


.
 
Back
Top