嗨,我有以下代码;
if( ! empty( $post['search-bar'] ) ) {
$search_data = preg_replace("#\s\s#is", '', preg_replace("#[^\w\d\s+]#is", '', $post['search-bar'] ) );
$data_array = explode( " ", $search_data );
$data_array = "'%" . implode( "%' OR '%", $data_array ) . "%'";
$query = "
SELECT CONCAT( PROFILE_PROFFESION, FIRST_NAME, LAST_NAME, DISPLAY_NAME) AS 'STRING'
FROM `" . ACCOUNT_TABLE . "`
WHERE STRING LIKE ( " . $data_array . " )
AND BUSINESS_POST_CODE LIKE '" . substr(P_BUSINESS_POST_CODE, 0, 4) . "%'";
$q = mysql_query( $query, $CON ) or die( "_error_" . mysql_error() );
if( mysql_num_rows( $q ) != 0 ) {
die();
}
}
问题是我想在 where 子句中使用 temp col 'STRING' 但返回 'unknown coloumnSTRING
任何人都可以指出我正确的方向,关于 Phil
我已经打印了查询;
SELECT PROFILE_PROFFESION, FIRST_NAME, LAST_NAME, DISPLAY_NAME
FROM nnn_accounts
WHERE
CONCAT( PROFILE_PROFFESION, FIRST_NAME, LAST_NAME, DISPLAY_NAME)
LIKE ( '%web%' OR '%design%' )
AND BUSINESS_POST_CODE LIKE 'NG19%'