ainoy31 Posted August 23, 2007 Share Posted August 23, 2007 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 https://forums.phpfreaks.com/topic/66359-solved-sql-pattern-matching/ Share on other sites More sharing options...
fenway Posted August 23, 2007 Share Posted August 23, 2007 Well, you can use RIGHT(yourField, 4).... Link to comment https://forums.phpfreaks.com/topic/66359-solved-sql-pattern-matching/#findComment-332063 Share on other sites More sharing options...
ainoy31 Posted August 23, 2007 Author Share Posted August 23, 2007 thanks man Link to comment https://forums.phpfreaks.com/topic/66359-solved-sql-pattern-matching/#findComment-332265 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.