# mySQL select and like query

**URL:** <https://forum.kirupa.com/t/mysql-select-and-like-query/320954>\
**Category:** programming\
**Created:** [April 6, 2011, 4:49pm UTC](https://forum.kirupa.com/t/mysql-select-and-like-query/320954 "2011-04-06T16:49:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Env](https://avatars.discourse-cdn.com/v4/letter/e/d9b06d/32.png) [@Env](https://forum.kirupa.com/u/Env)\
**Post date:** [April 6, 2011, 4:49pm UTC](https://forum.kirupa.com/t/mysql-select-and-like-query/320954/1 "2011-04-06T16:49:48Z")

</div>

MySQL Like for Postcodes

Trying to load mySQL information for postcode matching. The first two queries work but sometimes users dont place spaces between them… what is the solution please? I tried LIKE for a turn around as I thought it was most logical

SELECT \* FROM tblAccounts WHERE Email=‘john.smith@domain.com’ AND Postcode LIKE ‘m1 3tg’  
Works  
SELECT \* FROM tblAccounts WHERE Email=‘john.smith@domain.com’ AND Postcode LIKE ‘M1 3TG’  
Works

SELECT \* FROM tblAccounts WHERE Email=‘john.smith@domain.com’ AND Postcode LIKE ‘m13tg’  
Fail no rows returned  
SELECT \* FROM tblAccounts WHERE Email=‘john.smith@domain.com’ AND Postcode LIKE ‘M13TG’  
Fail no rows returned

The mySQL Table

DevRID Email Postcode  
1 [john.smith@domain.com](mailto:john.smith@domain.com) M1 3TG
