mcwdes Posted April 7, 2008 Share Posted April 7, 2008 Table 1 3 #1,#2 2 5 #2,#3 3 3 #1,#2,#3 4 4 #4 5 5 #1,#2,#3 6 5 #1,#2,#3 7 4 All 8 3 #1,#2,#3 Need to compare the value of field2 with the occurrences of "#" in field3. Tried this: $query_plcResultsSet = "SELECT * FROM Table WHERE RteType IN ('Mainline', 'Connector') AND StartDateD = '$strchvarval' AND (field2 = 'All' OR " . substr_count(field3, '#') . " = field2)"; I know this won't work and I think I know why, but don't know how to solve. Quote Link to comment Share on other sites More sharing options...
fenway Posted April 7, 2008 Share Posted April 7, 2008 It's not trivial to do substr_count() in mysql (at least without a UDF). Quote Link to comment Share on other sites More sharing options...
mcwdes Posted April 7, 2008 Author Share Posted April 7, 2008 Thank you fenway... I was aware that it is possible. Can't seem to find a similar example to steer me in the right direction. Quote Link to comment Share on other sites More sharing options...
fenway Posted April 7, 2008 Share Posted April 7, 2008 I'd be surprised if someone hasn't already written out... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.