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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.