我的数据库书中有三个表,作者,出版...我希望用户可以在三个表中搜索,如果他写了任何相关的单词。如果在 book 表中找不到相同的单词,它将在另一个表中搜索,依此类推……我这样做了,但有些事情错了,我想在一个 mysql 句子中找到它。请任何人帮助我
function getsomeword($keyword) {
$result1 = $this->db->query("SELECT bo_id,bo_name,bo_state,bo_about FROM d_book where (bo_name like '%$keyword%' or bo_about like '%$keyword%') and bo_state = '1'");
$result1 = $result1->num_rows();
$result2 = $this->db->query("SELECT au_id,au_name,au_state,au_info FROM d_author where (au_name like '%$keyword%' or au_info like '%$keyword%') and au_state = '1'");
$result2 = $result2->num_rows();
$result3 = $this->db->query("SELECT pub_id,pub_name,pub_state,pub_info FROM d_publishing where (pub_name like '%$keyword%' or pub_info like '%$keyword%') and pub_state = '1'");
$result3 = $result3->num_rows();
return $result1 + $result2 + $result3;
}