mysql - how to handle white spaces in sql -


i want write sql query fetch students live in specific post code. following query.

select * `students` ss ss.`postcode` 'se4 1na'; 

now issue in database records saved without white space postcode, se41na , may in lowercase, se41na or se4 1na.

the query gives me different results based on how record saved. there way in can handle this?

using regexp 1 way it. performs case insensitive match default.

select * students ss  ss.postcode regexp '^se4[[:space:]]?1na$'; 

[[:space:]]? matches optional space character.

regexp documentation mysql


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -