Thread: Case (in)sensitive
Hello! I have a database with city names, so the first letter is capitalised. I want to let the user search for part of the city name. How can I do case insensitive for this? You know "... like '%bud%';" won't find Budapest. Thanks in advance, Laszlo Boszormenyi
Hey, try a: "select * from city where lower(name) like '%bud%';", that should give you the name, of this nice city... Claus Boszormenyi Laszlo wrote: > > Hello! > > I have a database with city names, so the first letter is capitalised. > I want to let the user search for part of the city name. How can I do case > insensitive for this? You know "... like '%bud%';" won't find Budapest. > > Thanks in advance, > Laszlo Boszormenyi
You can use the regular expression (powerful pattern matching) syntax: SELECT * FROM xyz WHERE field ~* '.*bud'; The ~* is a case insensitive pattern match operator, and (as an example of a regular expression) '.*bud' matches zero or more characters followed by 'bud' For more info, see: http://www.postgresql.org/users-lounge/docs/7.0/user/operators2123.htm Hope that helps, Ol. Hello! I have a database with city names, so the first letter is capitalised. I want to let the user search for part of the city name. How can I do case insensitive for this? You know "... like '%bud%';" won't find Budapest. Thanks in advance, Laszlo Boszormenyi ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. SCEE **********************************************************************