Jump to content

[SOLVED] SQL Pattern Matching


ainoy31

Recommended Posts

Hi.

 

I have a scenario where I am trying to find a match in my query.

$query = "SELECT requestID FROM requests WHERE deptAirport = '$reqDeptAirport' AND destAirport = '$reqDestAirport' AND date = '$reqDate'";

 

My problem is that the info in the DB for the deptAiport and destAirport is a four letter code such as PADK.  However, on the website when the user makes a selection it could be a 4 to 10 letter code such as AMES MUN - KAMW.  I just need to match the last four letter code from the DB and the selection from the website.  I saw there is an operator REGEXP or '^.....$' that I can use.  I tried using the REGEXP like this: ...WHERE deptAirport REGEXP = '$reqDeptAirport' AND destAirport REGEXP = '$reqDestAirport'...

 

Much appreciation.

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.