Hello Group
I have a query that works in Oracle and SQL Server, but fails in Microsoft
Access.
The query is:
SELECT data fromTABLE1 WHERE data>='A&' AND data<'A'''
Here is my sample data:
TABLE1.DATA
Row1 A&M Stores
Row2 A&P Grocery
Row3 Assoc. Foods
Under Oracle and SQL Server the rows that are returned are Rows 1 and 2.
Under Access no rows are returned.
The goal is to write a SQL statement that works on all 3 platforms without
creating a customized query for each platform (or actually custom just for
Access). Please note that I know how to write a query that would work in
Access, but that query would use the InStr function which is not universally
available.
It is my theory that when Access (or Jet) executes the query it internally
executes the query as a LIKE type expression, and seeing that there are
special characters in the literal string this causes the query to return no
rows.
Thank you!
Joe
PS: Anyone emailing me responses are appreciated 12 2249
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
You can't use the same wild card character in all db engines. The "one
or more characters" wild card character in MS SQL & Oracle is the
ampersand (&); Access (JET) uses the asterisk (*). The "any one
character" wild card in MS SQL & Oracle is the underline (_); Access
(JET) uses the question-mark (?).
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQQ6J1oechKqOuFEgEQJO+wCg0CS3xN5VK7CIchd1L0SIbM az3K0AoPm1
oi27wjYZCoy8XKU0+AekmyO3
=fAcx
-----END PGP SIGNATURE-----
Joe Stanton wrote: Hello Group
I have a query that works in Oracle and SQL Server, but fails in Microsoft Access.
The query is:
SELECT data fromTABLE1 WHERE data>='A&' AND data<'A'''
Here is my sample data:
TABLE1.DATA Row1 A&M Stores Row2 A&P Grocery Row3 Assoc. Foods
Under Oracle and SQL Server the rows that are returned are Rows 1 and 2. Under Access no rows are returned.
The goal is to write a SQL statement that works on all 3 platforms without creating a customized query for each platform (or actually custom just for Access). Please note that I know how to write a query that would work in Access, but that query would use the InStr function which is not universally available.
It is my theory that when Access (or Jet) executes the query it internally executes the query as a LIKE type expression, and seeing that there are special characters in the literal string this causes the query to return no rows.
Thank you for the response, but the issue here is not using wildcards but
just finding data.
"MGFoster" <me@privacy.com> wrote in message
news:zR*****************@newsread1.news.pas.earthl ink.net... -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
You can't use the same wild card character in all db engines. The "one or more characters" wild card character in MS SQL & Oracle is the ampersand (&); Access (JET) uses the asterisk (*). The "any one character" wild card in MS SQL & Oracle is the underline (_); Access (JET) uses the question-mark (?).
-- MGFoster:::mgf00 <at> earthlink <decimal-point> net Oakland, CA (USA)
-----BEGIN PGP SIGNATURE----- Version: PGP for Personal Privacy 5.0 Charset: noconv
iQA/AwUBQQ6J1oechKqOuFEgEQJO+wCg0CS3xN5VK7CIchd1L0SIbM az3K0AoPm1 oi27wjYZCoy8XKU0+AekmyO3 =fAcx -----END PGP SIGNATURE-----
Joe Stanton wrote:
Hello Group
I have a query that works in Oracle and SQL Server, but fails in
Microsoft Access.
The query is:
SELECT data fromTABLE1 WHERE data>='A&' AND data<'A'''
Here is my sample data:
TABLE1.DATA Row1 A&M Stores Row2 A&P Grocery Row3 Assoc. Foods
Under Oracle and SQL Server the rows that are returned are Rows 1 and 2. Under Access no rows are returned.
The goal is to write a SQL statement that works on all 3 platforms
without creating a customized query for each platform (or actually custom just
for Access). Please note that I know how to write a query that would work
in Access, but that query would use the InStr function which is not
universally available.
It is my theory that when Access (or Jet) executes the query it
internally executes the query as a LIKE type expression, and seeing that there are special characters in the literal string this causes the query to return
no rows.
It looks to me that "A" < "A&" < "A&M ..." < "Assoc...", (in most of
alphabetical ordering methods and at least in JET alphabetical ordering).
so none of your Records meet the criteria
(Data >= 'A&') AND (Data < 'A')
(a "circular" greater than relationship which is impossible.)
and therefore none is selected.
--
HTH
Van T. Dinh
MVP (Access)
"Joe Stanton" <jo*@bravenewsoftware.com> wrote in message
news:ZS********************@newssvr29.news.prodigy .com... Hello Group
I have a query that works in Oracle and SQL Server, but fails in Microsoft Access.
The query is:
SELECT data fromTABLE1 WHERE data>='A&' AND data<'A'''
Here is my sample data:
TABLE1.DATA Row1 A&M Stores Row2 A&P Grocery Row3 Assoc. Foods
Under Oracle and SQL Server the rows that are returned are Rows 1 and 2. Under Access no rows are returned.
The goal is to write a SQL statement that works on all 3 platforms without creating a customized query for each platform (or actually custom just for Access). Please note that I know how to write a query that would work in Access, but that query would use the InStr function which is not
universally available.
It is my theory that when Access (or Jet) executes the query it internally executes the query as a LIKE type expression, and seeing that there are special characters in the literal string this causes the query to return
no rows.
Thank you! Joe
PS: Anyone emailing me responses are appreciated
"Joe Stanton" <jo*@bravenewsoftware.com> wrote in
news:ZS********************@newssvr29.news.prodigy .com: Hello Group
I have a query that works in Oracle and SQL Server, but fails in Microsoft Access.
The query is:
SELECT data fromTABLE1 WHERE data>='A&' AND data<'A'''
Here is my sample data:
TABLE1.DATA Row1 A&M Stores Row2 A&P Grocery Row3 Assoc. Foods
Under Oracle and SQL Server the rows that are returned are Rows 1 and 2. Under Access no rows are returned.
The goal is to write a SQL statement that works on all 3 platforms without creating a customized query for each platform (or actually custom just for Access). Please note that I know how to write a query that would work in Access, but that query would use the InStr function which is not universally available.
It is my theory that when Access (or Jet) executes the query it internally executes the query as a LIKE type expression, and seeing that there are special characters in the literal string this causes the query to return no rows.
Thank you! Joe
PS: Anyone emailing me responses are appreciated
I touched up your query to explain what I think is going on:,
SELECT data from TABLE1 WHERE data>=65+38 AND data<65
Seems to me that nothing should get returned in any version.
However, the <65 (the ascii value for A) may automatically be
doing a left() in SQL server and Oracle.
Using WHERE data LIKE "A&*" will work.
--
Bob Quintal
PA is y I've altered my email address.
It may have escaped notice, but the second operator in the string has 3
trailing single quotes, meaning that the data in the second operator is
actually (put on one line below for clarity):
A'
and so the properly constructed literal string in SQL is
'A'''
This SQL is constructed in this way due to the need to create a statement
that is acceptable (without tweaking) to Oracle, SQL Server, and Access. So
this requires using the single quote as the literal string delimiter as well
as not relying on LIKE (which has different wildcard characters for Access
and Oracle/SQL) or perhaps Instr, etc.
The user inputs the data A&. The program determines the next ASCII
character in sequence after the last character in the input (the &), and in
thise case determines it to be the single quote. And so the purpose is to
find all strings that start with A&.
"Bob Quintal" <rq******@sPAmpatico.ca> wrote in message
news:Xn**********************@66.150.105.49... "Joe Stanton" <jo*@bravenewsoftware.com> wrote in news:ZS********************@newssvr29.news.prodigy .com:
Hello Group
I have a query that works in Oracle and SQL Server, but fails in Microsoft Access.
The query is:
SELECT data fromTABLE1 WHERE data>='A&' AND data<'A'''
Here is my sample data:
TABLE1.DATA Row1 A&M Stores Row2 A&P Grocery Row3 Assoc. Foods
Under Oracle and SQL Server the rows that are returned are Rows 1 and 2. Under Access no rows are returned.
The goal is to write a SQL statement that works on all 3 platforms without creating a customized query for each platform (or actually custom just for Access). Please note that I know how to write a query that would work in Access, but that query would use the InStr function which is not universally available.
It is my theory that when Access (or Jet) executes the query it internally executes the query as a LIKE type expression, and seeing that there are special characters in the literal string this causes the query to return no rows.
Thank you! Joe
PS: Anyone emailing me responses are appreciated
I touched up your query to explain what I think is going on:, SELECT data from TABLE1 WHERE data>=65+38 AND data<65
Seems to me that nothing should get returned in any version. However, the <65 (the ascii value for A) may automatically be doing a left() in SQL server and Oracle.
Using WHERE data LIKE "A&*" will work.
-- Bob Quintal
PA is y I've altered my email address.
I just tried it in ACCESS 97 and it worked for me there. It returned two
records that started with A& and didn't return Anderson.
SELECT Text
FROM Test
WHERE Text>'A&' And Text<'A'''
So, what version of Access? What data engine (MSDE or JET)?
I believe that you will find some problems with later versions of Access and
Jet. MS decided to change the sort tables and some things just don't work as
they used to.
Joe Stanton wrote: It may have escaped notice, but the second operator in the string has 3 trailing single quotes, meaning that the data in the second operator is actually (put on one line below for clarity):
A'
and so the properly constructed literal string in SQL is
'A'''
This SQL is constructed in this way due to the need to create a statement that is acceptable (without tweaking) to Oracle, SQL Server, and Access. So this requires using the single quote as the literal string delimiter as well as not relying on LIKE (which has different wildcard characters for Access and Oracle/SQL) or perhaps Instr, etc.
The user inputs the data A&. The program determines the next ASCII character in sequence after the last character in the input (the &), and in thise case determines it to be the single quote. And so the purpose is to find all strings that start with A&.
"Bob Quintal" <rq******@sPAmpatico.ca> wrote in message news:Xn**********************@66.150.105.49... "Joe Stanton" <jo*@bravenewsoftware.com> wrote in news:ZS********************@newssvr29.news.prodigy .com:
Hello Group
I have a query that works in Oracle and SQL Server, but fails in Microsoft Access.
The query is:
SELECT data fromTABLE1 WHERE data>='A&' AND data<'A'''
Here is my sample data:
TABLE1.DATA Row1 A&M Stores Row2 A&P Grocery Row3 Assoc. Foods
Under Oracle and SQL Server the rows that are returned are Rows 1 and 2. Under Access no rows are returned.
The goal is to write a SQL statement that works on all 3 platforms without creating a customized query for each platform (or actually custom just for Access). Please note that I know how to write a query that would work in Access, but that query would use the InStr function which is not universally available.
It is my theory that when Access (or Jet) executes the query it internally executes the query as a LIKE type expression, and seeing that there are special characters in the literal string this causes the query to return no rows.
Thank you! Joe
PS: Anyone emailing me responses are appreciated
I touched up your query to explain what I think is going on:, SELECT data from TABLE1 WHERE data>=65+38 AND data<65
Seems to me that nothing should get returned in any version. However, the <65 (the ascii value for A) may automatically be doing a left() in SQL server and Oracle.
Using WHERE data LIKE "A&*" will work.
-- Bob Quintal
PA is y I've altered my email address.
Interesting... I am using Access 2000 for this test, and in the VB
application it is via DAO/Jet 3.6. Thanks for the info that it used to work
and now doesn't - sheds some light on the confusion.
So, returning to the oroginal question, how then can a query be crafted that
will work correctly on these 3 platforms (Oracle 8i/9i, SQL Server 7/2000,
Access 97/2000/XP/2003)?
I had the idea of using the Left function, but have not yet determined it's
implementation on the enterprise backends.
"John Spencer (MVP)" <sp******@comcast.net> wrote in message
news:41***************@comcast.net... I just tried it in ACCESS 97 and it worked for me there. It returned two records that started with A& and didn't return Anderson.
SELECT Text FROM Test WHERE Text>'A&' And Text<'A'''
So, what version of Access? What data engine (MSDE or JET)?
I believe that you will find some problems with later versions of Access
and Jet. MS decided to change the sort tables and some things just don't work
as they used to.
Joe Stanton wrote: It may have escaped notice, but the second operator in the string has 3 trailing single quotes, meaning that the data in the second operator is actually (put on one line below for clarity):
A'
and so the properly constructed literal string in SQL is
'A'''
This SQL is constructed in this way due to the need to create a
statement that is acceptable (without tweaking) to Oracle, SQL Server, and Access.
So this requires using the single quote as the literal string delimiter as
well as not relying on LIKE (which has different wildcard characters for
Access and Oracle/SQL) or perhaps Instr, etc.
The user inputs the data A&. The program determines the next ASCII character in sequence after the last character in the input (the &), and
in thise case determines it to be the single quote. And so the purpose is
to find all strings that start with A&.
"Bob Quintal" <rq******@sPAmpatico.ca> wrote in message news:Xn**********************@66.150.105.49... "Joe Stanton" <jo*@bravenewsoftware.com> wrote in news:ZS********************@newssvr29.news.prodigy .com:
> Hello Group > > I have a query that works in Oracle and SQL Server, but fails > in Microsoft Access. > > The query is: > > SELECT data fromTABLE1 WHERE data>='A&' AND data<'A''' > > Here is my sample data: > > TABLE1.DATA > Row1 A&M Stores > Row2 A&P Grocery > Row3 Assoc. Foods > > Under Oracle and SQL Server the rows that are returned are > Rows 1 and 2. Under Access no rows are returned. > > The goal is to write a SQL statement that works on all 3 > platforms without creating a customized query for each > platform (or actually custom just for Access). Please note > that I know how to write a query that would work in Access, > but that query would use the InStr function which is not > universally available. > > It is my theory that when Access (or Jet) executes the query > it internally executes the query as a LIKE type expression, > and seeing that there are special characters in the literal > string this causes the query to return no rows. > > Thank you! > Joe > > PS: Anyone emailing me responses are appreciated > >
I touched up your query to explain what I think is going on:, SELECT data from TABLE1 WHERE data>=65+38 AND data<65
Seems to me that nothing should get returned in any version. However, the <65 (the ascii value for A) may automatically be doing a left() in SQL server and Oracle.
Using WHERE data LIKE "A&*" will work.
-- Bob Quintal
PA is y I've altered my email address.
Don't know what will work.
Perhaps you could use something like:
WHERE Text >'A&' AND Text <'A&ZZZZZZZ'
By the way, I just confirmed (as if you needed it) that I get the same behavior
as you in Access 2000
Joe Stanton wrote: Interesting... I am using Access 2000 for this test, and in the VB application it is via DAO/Jet 3.6. Thanks for the info that it used to work and now doesn't - sheds some light on the confusion.
So, returning to the oroginal question, how then can a query be crafted that will work correctly on these 3 platforms (Oracle 8i/9i, SQL Server 7/2000, Access 97/2000/XP/2003)?
I had the idea of using the Left function, but have not yet determined it's implementation on the enterprise backends.
"John Spencer (MVP)" <sp******@comcast.net> wrote in message news:41***************@comcast.net... I just tried it in ACCESS 97 and it worked for me there. It returned two records that started with A& and didn't return Anderson.
SELECT Text FROM Test WHERE Text>'A&' And Text<'A'''
So, what version of Access? What data engine (MSDE or JET)?
I believe that you will find some problems with later versions of Access and Jet. MS decided to change the sort tables and some things just don't work as they used to.
Joe Stanton wrote: It may have escaped notice, but the second operator in the string has 3 trailing single quotes, meaning that the data in the second operator is actually (put on one line below for clarity):
A'
and so the properly constructed literal string in SQL is
'A'''
This SQL is constructed in this way due to the need to create a statement that is acceptable (without tweaking) to Oracle, SQL Server, and Access. So this requires using the single quote as the literal string delimiter as well as not relying on LIKE (which has different wildcard characters for Access and Oracle/SQL) or perhaps Instr, etc.
The user inputs the data A&. The program determines the next ASCII character in sequence after the last character in the input (the &), and in thise case determines it to be the single quote. And so the purpose is to find all strings that start with A&.
"Bob Quintal" <rq******@sPAmpatico.ca> wrote in message news:Xn**********************@66.150.105.49... > "Joe Stanton" <jo*@bravenewsoftware.com> wrote in > news:ZS********************@newssvr29.news.prodigy .com: > > > Hello Group > > > > I have a query that works in Oracle and SQL Server, but fails > > in Microsoft Access. > > > > The query is: > > > > SELECT data fromTABLE1 WHERE data>='A&' AND data<'A''' > > > > Here is my sample data: > > > > TABLE1.DATA > > Row1 A&M Stores > > Row2 A&P Grocery > > Row3 Assoc. Foods > > > > Under Oracle and SQL Server the rows that are returned are > > Rows 1 and 2. Under Access no rows are returned. > > > > The goal is to write a SQL statement that works on all 3 > > platforms without creating a customized query for each > > platform (or actually custom just for Access). Please note > > that I know how to write a query that would work in Access, > > but that query would use the InStr function which is not > > universally available. > > > > It is my theory that when Access (or Jet) executes the query > > it internally executes the query as a LIKE type expression, > > and seeing that there are special characters in the literal > > string this causes the query to return no rows. > > > > Thank you! > > Joe > > > > PS: Anyone emailing me responses are appreciated > > > > > > I touched up your query to explain what I think is going on:, > SELECT data from TABLE1 WHERE data>=65+38 AND data<65 > > Seems to me that nothing should get returned in any version. > However, the <65 (the ascii value for A) may automatically be > doing a left() in SQL server and Oracle. > > Using WHERE data LIKE "A&*" will work. > > -- > Bob Quintal > > PA is y I've altered my email address.
BTW, thanks for the assistance. I am glad for the confirmation. Will get
this idea for the Left check tested later. The developer I am assisting
went to the dentist and will be back later tomorrow.
"John Spencer (MVP)" <sp******@comcast.net> wrote in message
news:41***************@comcast.net... Don't know what will work.
Perhaps you could use something like:
WHERE Text >'A&' AND Text <'A&ZZZZZZZ'
By the way, I just confirmed (as if you needed it) that I get the same
behavior as you in Access 2000
"Joe Stanton" <jo*@bravenewsoftware.com> wrote in
news:Jh*****************@newssvr21.news.prodigy.co m: It may have escaped notice, but the second operator in the string has 3 trailing single quotes, meaning that the data in the second operator is actually (put on one line below for clarity):
A'
and so the properly constructed literal string in SQL is
'A'''
Sorry, I need glasses.
I played around with this and discovered that DATA <"A'" double
quotes also fails to return records, but going from ' to (, char 39
to 40 works., with the literal in single or double quotes, and can
be created from the query builder or in code..
I discovered that DATA <'A''' fails to return records.
I also found that DATA >='O''' returns O'Clare and O'Hare, as well
as everything above, but when coupled with AND DATA <"Oz" returns
nothing.
So it seems that when using the < or <=, something in Jet breaks.
This behaviour is in my opinion a "BUG".
--
Bob Quintal
PA is y I've altered my email address.
Sorry that I missed the single-quote before.
This is possibly the behaviour of JET 4 (default engine in Access 2000)
which is different from JET 3.5 (A97).
There is an article on Microsoft Web site about this sorting. See: http://support.microsoft.com/?id=236952
--
HTH
Van T. Dinh
MVP (Access)
"Joe Stanton" <jo*@bravenewsoftware.com> wrote in message
news:Og***************@newssvr21.news.prodigy.com. .. Interesting... I am using Access 2000 for this test, and in the VB application it is via DAO/Jet 3.6. Thanks for the info that it used to
work and now doesn't - sheds some light on the confusion.
So, returning to the oroginal question, how then can a query be crafted
that will work correctly on these 3 platforms (Oracle 8i/9i, SQL Server 7/2000, Access 97/2000/XP/2003)?
I had the idea of using the Left function, but have not yet determined
it's implementation on the enterprise backends.
Joe,
I don't have AC2K to test this on, but what about using BETWEEN and a
not-equal combined? It is supported in both Access and SQL-Server (I
don't know about Oracle, but I would assume that it works there too).
SELECT data FROM TABLE1 WHERE (data BETWEEN 'A&' AND 'A''') AND data <>
'A'''
Bri
Joe Stanton wrote: Interesting... I am using Access 2000 for this test, and in the VB application it is via DAO/Jet 3.6. Thanks for the info that it used to work and now doesn't - sheds some light on the confusion.
So, returning to the oroginal question, how then can a query be crafted that will work correctly on these 3 platforms (Oracle 8i/9i, SQL Server 7/2000, Access 97/2000/XP/2003)?
I had the idea of using the Left function, but have not yet determined it's implementation on the enterprise backends. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Phil Powell |
last post by:
Here is the scope of what I need to do;
want:
enrollment_year
allowed (even if null)
all of ica
criteria:
|
by: Philip Yale |
last post by:
A colleague of mine has a query which fails to run under SQLAgent
batch with the following error:
The conversion of a char data type to a datetime data type resulted in
an out-of-range datetime...
|
by: GTi |
last post by:
I have a query like:
SELECT "ProjectMembers"."RoleText", "ProjectMembers"."Description",
"ContactTable"."Name1", "ContactTable"."Name2", "ContactTable1"."Name1",
"ContactTable1"."Name2" FROM...
|
by: MX1 |
last post by:
Simpler way to ask question from my previous post. I wrote a query and it
has a paramter field in it. I want to enter a date with the current year.
If it I put in 6/30/2003, it works great. If I...
|
by: Stephen Bowyer |
last post by:
I have an Access 97 database, which we use with a VB5 front end.
If I create a new query in the database, the string functions left, mid etc
do not work.
For example the query:
CalcField:...
|
by: Winterminute |
last post by:
I am trying to read a list of install programs using WMI with ASP.NET/C#.
However, it fails with "Invalid Class".
I have confirmed that if I query LOCALHOST then it works fine, but if I
query a...
|
by: Jimmy |
last post by:
I have a form with a command button on it that is supposed to open up a
report and use a query to populate it.
DoCmd.OpenReport "rptMailingList", acViewPreview, "qryMailingListChristmas"
...
|
by: russellhq |
last post by:
Hi, I'm fairly new to access and have a little trouble with a crosstab query I've setup.
I have a main form where the user selects a project name and below in a subform, a crosstab query is...
|
by: ARC |
last post by:
Hello all,
So I'm knee deep in this import utility program, and am coming up with all
sorts of "gotcha's!".
1st off. On a "Find Duplicates Query", does anyone have a good solution for...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |