473,399 Members | 2,278 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,399 software developers and data experts.

Case insensitive search (MySQL)

Hello,

I'm looking for solution in case insensitive search in MySql.

Table exemple.

CREATE TABLE `pozycje` (
`id` int(11) NOT NULL auto_increment,
`eid` varchar(20) collate latin2_bin default NULL,
`poz_nazwa` varchar(40) collate latin2_bin NOT NULL,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
CONSTRAINT `pozycje_fk_user` FOREIGN KEY (`user_id`) REFERENCES
`users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin2 COLLATE=latin2_bin
COMMENT='InnoDB free: 0 kB; (`user_id`) ;

Data in table

id eid poz_nazwa
__________________________________________________
401 1 401-B12-1 Wrotki Band

402 1 402-B12-1 Wrotki Band

403 1 403-B12-3 Roman Giertych
Inc.
404 1 23-22-22 Greg Johan Inc.

405 1 25-21-45 Greg Johan Inc.

406 1 33-34-88 Greg Johan Inc.

407 1 45-09-22 Greg Johan Inc.

408 1 54-23-89 Greg Johan Inc.

409 1 09-65-43 Giertych INC

410 1 33-11-87 Greg Johan Inc.

Search Query:
SELECT * FROM pozycje Where poz_nazwa Like "%greg%"

Results: NONE!!!! WHY

Im looking for that:
Search Query:
SELECT * FROM pozycje Where poz_nazwa Like "%greg%"

Results: Found 6 rows

id eid poz_nazwa
__________________________________________________
404 1 23-22-22 Greg Johan Inc.

405 1 25-21-45 Greg Johan Inc.

406 1 33-34-88 Greg Johan Inc.

407 1 45-09-22 Greg Johan Inc.

408 1 54-23-89 Greg Johan Inc.
410 1 33-11-87 Greg Johan Inc.
Thanks for any response

Jan 25 '07 #1
1 35392
On Thu, 25 Jan 2007 01:24:07 -0800, iksando wrote:
Hello,

I'm looking for solution in case insensitive search in MySql.

Table exemple.

CREATE TABLE `pozycje` (
`id` int(11) NOT NULL auto_increment,
`eid` varchar(20) collate latin2_bin default NULL,
`poz_nazwa` varchar(40) collate latin2_bin NOT NULL,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
CONSTRAINT `pozycje_fk_user` FOREIGN KEY (`user_id`) REFERENCES
`users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin2 COLLATE=latin2_bin
COMMENT='InnoDB free: 0 kB; (`user_id`) ;

Data in table
<snip>
>
Search Query:
SELECT * FROM pozycje Where poz_nazwa Like "%greg%"

Results: NONE!!!! WHY
Because - the field [poz_nazwa] is specified "collate latin2_bin"
The "_bin" suggests Binary. Looking that up in the MySQL docs:

Collation Meaning
.....
latin1_bin Binary according to latin1 encoding

showing that it is indeed "Binary". Binary means that it will
compare case *sensitive* on that field. You will need to change
that collation in the field definition -
Or
you could force all uppercase with UCASE().
SELECT * FROM pozycje Where UCASE(poz_nazwa) Like UCASE("%greg%")
which effectively makes string comparisons case insensitive despite the
Binary character set chosen.

Thomas Bartkus
Jan 26 '07 #2

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

Similar topics

3
by: cowboyx | last post by:
Is there a way to configure PHP to use case-insensitive variable names? I'd like to do this... $dbVars = pg_query( $connection, "SELECT columnName1, columnName2, columnName3 FROM table WHERE...
5
by: Madjid Nasiri | last post by:
Hi, I am basic in oracle. My Old programs write with Delphi and Databases: Access, Paradox, MySQL, Microsoft SQL. I write my code (SQL code) case-insensitivae, but now i need use oracle database....
2
by: Tom | last post by:
Hi, Our development team is adding DB2 8.1 compatibility to our existing application which currently supports SQLServer 2000. Our code is written to take advantage of SQLServer's ability to ...
10
by: JohnR | last post by:
I have an arraylist of string values. I would like to search the arraylist to find the index of a particular string and I would like the search to be case insensitive. dim al as new arraylist...
2
by: John | last post by:
Does anyone know how to how to performance case-insensitive search on XML data type in SQLServer 2005? Or I have to convert all the xml data to lower case before I store it? Thanks in advance....
1
by: benhoefer | last post by:
I have been searching around and have not been able to find any info on this. I have a unique situation where I need a case sensitive map: std::map<string, intimap; I need to be able to run a...
4
by: bb | last post by:
Hi, void fun(const std::map<std::string,int>& m1) { // How to make a case insensitive search of this map without making a copy? } cheers.
6
by: Derik | last post by:
Okay, I THINK this is a PHP question... I've been mucking with PHP for awhile now, but just recently I've been poking at some ajax stuff, and I ran into something confusing; my Queries were...
0
by: J. Cliff Dyer | last post by:
Please keep the discussion on-list. On Fri, 2008-09-05 at 15:36 +0200, Maric Michaud wrote: That does not get the same behavior as the OP's original solution. The OP's solution retrieves the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.