<./>.dev./hood

select count(*) from table where num = '1234' and barcode REGEXP 'b2222_[1-count]$'; 

$a = barcodeExists($order_num, $barcode, $option_count); //echo $a['0'] . "++++++++++" . $a['1'] . "++++++++++" . $a['2']; function barcodeExists($order_num, $barcode){ //for($i = 1; $i <= $option_count; $i++){ $strSql = ""; $strSql .= " select "; $strSql .= " count(*) "; $strSql .= " from order_detail "; $strSql .= " where 1=1 "; $strSql .= " and status = 0 "; $strSql .= " and order_num = '".$order_num."' "; //$strSql .= " and barcode = '".$barcode."^".$i."' "; $strSql .= " and barcode REGEXP '".$barcode."_[1-count]$' "; echo $strSql; //} //$rtnvalue[] = mysql_result(mysql_query($strSql), 0, 0); $rtnvalue[] = mysql_num_rows(mysql_query($strSql)); return $rtnvalue; }