Jump to content

LIKE statement for postcodes


wright67uk

Recommended Posts

Im a newbie trying to get my head around php and sql, please can anyone help me with a statement,

or point me to a place where I can find out? - have tried w3schools.

 

How can I get my like statement to only compare the first two charracters of a value?

 

Let's say $code = EN7 6PX  (user has typed this into a html form)

for eg . SELECT email FROM treesurgeons WHERE postcode LIKE '%$code%'

 

How can I tell my like statement to only take notice of the first two charracters of the post code (in this case 'EN')?

 

So that I get returned EN4 1PP, EN5 6RT, EN7 3OL etc.

Link to comment
https://forums.phpfreaks.com/topic/226860-like-statement-for-postcodes/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.