-1

テーブルを検索する必要がありhostelます。

構造:

CREATE TABLE hostel( 
p_id VARCHAR(5) NOT NULL,
hostel VARCHAR(50) NOT NULL,
address VARCHAR(50) NOT NULL
PRIMARY KEY(p_id));

検索語を挿入しました$word

select * from hostel where hostel like '%$word%'

以下のクエリは機能しますか? 「ホステル」と「住所」の両方の列で検索する必要があります

select * from hostel where hostel like '%$word%' AND address like '%$word%'
4

3 に答える 3

2
select * from hostel where hostel like '%$word%' OR address like '%$word%'

より良い結果をもたらします

于 2012-12-14T10:45:52.913 に答える
2
Better change those searchable fields(hostel,address) to full text which will fasten the search

SELECT MATCH('Content') AGAINST ('keyword1
keyword2') as Relevance FROM table 

select match($word) against (hostel,address)  as Relevance FROM table 
于 2012-12-14T11:33:23.010 に答える
0

これは問題なく動作します

select * from hostel where hostel like '%$word%' AND address like '%$word%'
于 2012-12-14T10:45:22.403 に答える