0
我正在創建一個與購物者(姓名,地址)相匹配的銀行對賬單(描述,價值,類型等)的在線系統,並希望對我目前的行爲做一些反饋這樣的:MySQL查詢搜索通過相對匹配排序的關鍵字
$array = array("keywords", "taken", "from",
"bank", "statements", "using", "explode",
"function", "using", "a", "space");
$i = 0;
$r = array(); //r = relevant
while($i<count($array)) {
$keyword = $array[$i];
$get = mysql_query("SELECT `id` FROM `users`, `addresses`
LEFT JOIN `users`.`id` = `addresses`.`user`
WHERE (`users`.`frame` LIKE '%$keyword%'
OR `users`.`lname` LIKE '%$keyword%')
OR ((`addresses`.`address` LIKE '%$keyword%'
OR `addresses`.`town` LIKE '%$keyword%')
OR (`addresses`.`county` LIKE '%$keyword%'
OR `postcode`.`town` LIKE '%$keyword%'));");
if(mysql_num_rows($get)) {
while($fetch = mysql_fetch_array($get)) {
list($var) = $fetch;
push_array($r, $var);
}
}
$i++;
}
//count the IDs that match within the relative array to see
//which is most relative to the search
是否有這樣做,以及保持執行時間降到最低的一個更好的辦法?數據庫完成後將處於數千個數據庫中。