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. Link to comment https://forums.phpfreaks.com/topic/99982-select-query-compare-value-of-one-field-with-parsed-value-of-another-field/ 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). Link to comment https://forums.phpfreaks.com/topic/99982-select-query-compare-value-of-one-field-with-parsed-value-of-another-field/#findComment-511263 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. Link to comment https://forums.phpfreaks.com/topic/99982-select-query-compare-value-of-one-field-with-parsed-value-of-another-field/#findComment-511278 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... Link to comment https://forums.phpfreaks.com/topic/99982-select-query-compare-value-of-one-field-with-parsed-value-of-another-field/#findComment-511383 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.