Обсуждение: Case sensitivity
Hi, Well while moving from Mysql to POstgresql this was one more difference : Case Sensitivity. The problem is in this query select * from table where name='Word' select * from table where name='word' Mysql treated both as same but postgres does not..i appreciate that it is good but is there a way that 'Word' can be matched with 'word'? i mean my queries can specify whether to be case sensitive or not. is there any such provision in postgres? or is it always case sensitive? thanks -- ------ Varun It is easier to write an incorrect program than understand a correct one
Ok the way around this is SELECT * FROM table WHERE LOWER(name) = LOWER('Word'); SEELCT * FROM table WHERE UPPER(name) = UPPER('Word'); Note that if you have indexes on these fields then they will not work when upper and lower are used. To use an index create an index on upper or lower name depending upon what you want to use HTH Darren Ferguson On Thu, 20 Jun 2002, Varun Kacholia wrote: > Hi, > Well while moving from Mysql to POstgresql this was one more difference > : Case Sensitivity. > The problem is in this query > select * from table where name='Word' > select * from table where name='word' > > Mysql treated both as same but postgres does not..i appreciate that > it is good but is there a way that 'Word' can be matched with 'word'? > i mean my queries can specify whether to be case sensitive or not. > is there any such provision in postgres? > or is it always case sensitive? > thanks > -- Darren Ferguson
On Thu, Jun 20, 2002 at 07:53:06PM +0530, Varun Kacholia wrote: > Hi, > Well while moving from Mysql to POstgresql this was one more difference > : Case Sensitivity. > The problem is in this query > select * from table where name='Word' > select * from table where name='word' > > Mysql treated both as same Really!? Wow. Is there a way to differentiate 'Word' from 'word', then? (I mean, LeBlanc and Leblanc are not the same, when you're addressing people. And if you think the difference isn't important, you've never been to Acadia!) > it is good but is there a way that 'Word' can be matched with 'word'? Sure. Use ILIKE: SELECT * FROM table WHERE name ILIKE 'word'; A -- ---- Andrew Sullivan 87 Mowat Avenue Liberty RMS Toronto, Ontario Canada <andrew@libertyrms.info> M6K 3E3 +1 416 646 3304 x110