쿼리문 정규식 _ 내 해당하는 값 찾기
DB/MySQL - MariaDB2017. 2. 20. 19:59
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; }
'DB > MySQL - MariaDB' 카테고리의 다른 글
MySQL에서 DATETIME 형식 데이터 고속 검색 방법 (3) | 2017.03.08 |
---|---|
Mysql 에서 실행계획을 분석하는 방법 (0) | 2017.03.08 |
select 구문와 count 구문을 left join 으로 동시에 출력 (0) | 2016.01.03 |
int 형 칼럼을 date 형 쿼리로 불러오기 (0) | 2015.08.07 |
T-SQL, ANSI SQL 쿼리문 둘다 사용하기 (0) | 2015.07.26 |