473,395 Members | 2,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Case sensetive query

Hi
I am trying to do the following.
I have a set of records
Example
1 Test
2 test
3 TEST
4 ACCESS
5 EXCEL

If I'm running a query with a count I am getting the following result
record number of records
test 3
access 1
excel 1
My question is how can I make the query casesensetive so that my
query output
will be
record number of records
Test 1
test 1
TEST 1
Access 1
Excel 1

This means that the query shouldn't count test as one record but as 3
seperate records because there is a difference in the upper and lower
cases.

Thanks in advance

Ajay
Nov 12 '05 #1
6 2376
aj*******@yahoo.com (Ajay) wrote in
news:49*************************@posting.google.co m:
Hi
I am trying to do the following.
I have a set of records
Example
1 Test
2 test
3 TEST
4 ACCESS
5 EXCEL

If I'm running a query with a count I am getting the following result
record number of records
test 3
access 1
excel 1
My question is how can I make the query casesensetive so that my
query output
will be
record number of records
Test 1
test 1
TEST 1
Access 1
Excel 1

This means that the query shouldn't count test as one record but as 3
seperate records because there is a difference in the upper and lower
cases.


You might TRY (after backing up your table) changing the field type to
Binary.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #2
Lyle Fairfield <Mi************@Invalid.Com> wrote in
news:Xn*******************@130.133.1.4:
aj*******@yahoo.com (Ajay) wrote in
news:49*************************@posting.google.co m:
Hi
I am trying to do the following.
I have a set of records
Example
1 Test
2 test
3 TEST
4 ACCESS
5 EXCEL

If I'm running a query with a count I am getting the following result
record number of records
test 3
access 1
excel 1
My question is how can I make the query casesensetive so that my
query output
will be
record number of records
Test 1
test 1
TEST 1
Access 1
Excel 1

This means that the query shouldn't count test as one record but as 3
seperate records because there is a difference in the upper and lower
cases.


You might TRY (after backing up your table) changing the field type to
Binary.


If you are using XP you could use:

CurrentProject.Connection.Execute "ALTER TABLE tbl2002Transactions ALTER
fldDescription Binary"

I think this will work for 2K as well.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #3
"Ajay" <aj*******@yahoo.com> wrote in message
news:49*************************@posting.google.co m...
Hi
I am trying to do the following.
I have a set of records
Example
1 Test
2 test
3 TEST
4 ACCESS
5 EXCEL

If I'm running a query with a count I am getting the following result
record number of records
test 3
access 1
excel 1
My question is how can I make the query casesensetive so that my
query output
will be
record number of records
Test 1
test 1
TEST 1
Access 1
Excel 1

This means that the query shouldn't count test as one record but as 3
seperate records because there is a difference in the upper and lower
cases.

Thanks in advance

Ajay

As an alternative to Lyle's which does not involve changing data types you
could simply write a query. Asuming the data 'Test', 'test', 'TEST' etc is
held in a field called MyField in the table MyTable, then the query would
be:

SELECT MyField, Count(*) AS MyTotal
FROM MyTable
GROUP BY MyField, GetAscString([MyField])

You would simply have to paste the following function into a code module:

' ************************************************** ***
Public Function GetAscString(varInput) As String

Dim lngCount As Long
Dim strOut As String

If Len(varInput) > 0 Then
For lngCount = 1 To Len(varInput)
strOut = strOut & Asc(Mid$(varInput, lngCount, 1))
Next lngCount
End If

GetAscString = strOut

End Function

' ************************************************** ***
HTH

Fletcher
Nov 12 '05 #4
TC

"Fletcher Arnold" <fl****@home.com> wrote in message
news:bn**********@sparta.btinternet.com...

(snip)
As an alternative to Lyle's which does not involve changing data types you
could simply write a query. Asuming the data 'Test', 'test', 'TEST' etc is held in a field called MyField in the table MyTable, then the query would
be:

SELECT MyField, Count(*) AS MyTotal
FROM MyTable
GROUP BY MyField, GetAscString([MyField])

You would simply have to paste the following function into a code module:

' ************************************************** ***
Public Function GetAscString(varInput) As String

Dim lngCount As Long
Dim strOut As String

If Len(varInput) > 0 Then
For lngCount = 1 To Len(varInput)
strOut = strOut & Asc(Mid$(varInput, lngCount, 1))
Next lngCount
End If

GetAscString = strOut

End Function

' ************************************************** ***

You would want to pad the Asc values to a fixed length, eg:
format(asc(...), "000").

Otherwise, you don't know whether "12345" was 1, 23, 45 or: 123, 45 or: 1,
234, 5 etc. - so in principle, you could erroneously match those three
strings, as just one string.

I realize this might not happen with the actual numbers in question. But as
a matter of principle, it would be safer to do the fixed-length thing.

TC

Nov 12 '05 #5
"TC" <a@b.c.d> wrote in message news:1066802481.214681@teuthos...

"Fletcher Arnold" <fl****@home.com> wrote in message
news:bn**********@sparta.btinternet.com...

(snip)
As an alternative to Lyle's which does not involve changing data types you could simply write a query. Asuming the data 'Test', 'test', 'TEST' etc is
held in a field called MyField in the table MyTable, then the query would be:

SELECT MyField, Count(*) AS MyTotal
FROM MyTable
GROUP BY MyField, GetAscString([MyField])

You would simply have to paste the following function into a code module:
' ************************************************** ***
Public Function GetAscString(varInput) As String

Dim lngCount As Long
Dim strOut As String

If Len(varInput) > 0 Then
For lngCount = 1 To Len(varInput)
strOut = strOut & Asc(Mid$(varInput, lngCount, 1))
Next lngCount
End If

GetAscString = strOut

End Function

' ************************************************** ***

You would want to pad the Asc values to a fixed length, eg:
format(asc(...), "000").

Otherwise, you don't know whether "12345" was 1, 23, 45 or: 123, 45 or: 1,
234, 5 etc. - so in principle, you could erroneously match those three
strings, as just one string.

I realize this might not happen with the actual numbers in question. But

as a matter of principle, it would be safer to do the fixed-length thing.

TC

Hi TC
This did cross my mind, however if you look at the select query, you will
see that I group first by MyField then by GetAscString([MyField]). This
means that the first 'group by' looks at the string - it doesn't need to
'understand' the code to correctly group 'test', 'Test' and 'TEST' together,
and 'one', two', 'three' apart. In other words, with the word 'test' for
example, 116,101,115,116 is already correctly grouped as the word 'test' -
it couldn't be grouped as 11,61,01,115,116.
It is only when (ignoring upper/lower case) the word is the same, that the
second 'group by' is needed and even then, the code generated is not in the
select clause so the user doesn't see it.
Therefore, I can't see a case (even theoretical) where this query would not
correctly group a list of words. However, experience has taught me to
anticipate being corrected.
Regards

Fletcher
Nov 12 '05 #6
TC

"Fletcher Arnold" <fl****@home.com> wrote in message
news:bn**********@sparta.btinternet.com...
"TC" <a@b.c.d> wrote in message news:1066802481.214681@teuthos...

"Fletcher Arnold" <fl****@home.com> wrote in message
news:bn**********@sparta.btinternet.com...

(snip)
As an alternative to Lyle's which does not involve changing data types you could simply write a query. Asuming the data 'Test', 'test', 'TEST'
etc
is
held in a field called MyField in the table MyTable, then the query would be:

SELECT MyField, Count(*) AS MyTotal
FROM MyTable
GROUP BY MyField, GetAscString([MyField])

You would simply have to paste the following function into a code module:
' ************************************************** ***
Public Function GetAscString(varInput) As String

Dim lngCount As Long
Dim strOut As String

If Len(varInput) > 0 Then
For lngCount = 1 To Len(varInput)
strOut = strOut & Asc(Mid$(varInput, lngCount, 1))
Next lngCount
End If

GetAscString = strOut

End Function

' ************************************************** ***

You would want to pad the Asc values to a fixed length, eg:
format(asc(...), "000").

Otherwise, you don't know whether "12345" was 1, 23, 45 or: 123, 45 or:

1, 234, 5 etc. - so in principle, you could erroneously match those three
strings, as just one string.

I realize this might not happen with the actual numbers in question. But

as
a matter of principle, it would be safer to do the fixed-length thing.

TC

Hi TC
This did cross my mind, however if you look at the select query, you will
see that I group first by MyField then by GetAscString([MyField]). This
means that the first 'group by' looks at the string - it doesn't need to
'understand' the code to correctly group 'test', 'Test' and 'TEST'

together, and 'one', two', 'three' apart. In other words, with the word 'test' for
example, 116,101,115,116 is already correctly grouped as the word 'test' -
it couldn't be grouped as 11,61,01,115,116.
It is only when (ignoring upper/lower case) the word is the same, that the
second 'group by' is needed and even then, the code generated is not in the select clause so the user doesn't see it.
Therefore, I can't see a case (even theoretical) where this query would not correctly group a list of words. However, experience has taught me to
anticipate being corrected.
Regards

Fletcher

Ah, you are exactly right!

Cheers,
TC

Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: C# newbie | last post by:
Hi, How can I make my query to return both "Bob" & "bob" (during search for a string) ? any idea? thanks
2
by: vulcaned | last post by:
Hi All, In access97 I have a query who's record source is a linked sql table and when I enter a value the Part nbr filed to select by (ex: A10295X ) I get back only records that have a case match....
5
by: Jeff S | last post by:
I'm getting started with C# and was just wondering if C# veterans LIKE the fact that the language is case sensitive. If so, how is case sensitivity helpful? Do you create multiple variables,...
15
by: Thomas Scheiderich | last post by:
I thought I read that the case for the variable names is important. For example Dim Wheel As Integer Wheel here is a different variable from WHEEL. Is this correct?
1
by: Agnes | last post by:
myGrid.mappingname = "Invoice" -> it doesn't work myGrid.mappingname = "invoice" -> it seems work . Case sensetive ?
10
by: Agnes | last post by:
I found that store procedure with vb.net (seems ignore case senstive) I type "lax" as code, and it returns the correct answer , How come ?? I can't set the upper case in that textbox, BUT I need...
2
by: A Bruce | last post by:
hello, I am attempting to convert a oracle database to postgresql and I am having some problems creating a constraint across multiple columns which are a mixture of case insensitive and case...
0
by: ambika_se | last post by:
Hi all I want to make a Xquery which is like this for $x in doc("file:///C:/Science.xml")//tva2:title where $x//node() return $x Its working perfectly but if i try for( biological science) its...
7
by: vunet.us | last post by:
So, I came across the problem every developer comes across with once: case in SQL. My users login with their selected user name and when SQL checks for user name value, case is ignored. For...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.