Mysql 如何索引sql数据库以使用匹配查询
我想在我的sql中对以下地理位置查询使用匹配查询:-Mysql 如何索引sql数据库以使用匹配查询,mysql,drupal,phpmyadmin,Mysql,Drupal,Phpmyadmin,我想在我的sql中对以下地理位置查询使用匹配查询:- SELECT location.lid, location_instance.uid, users.name , users.mail , location.latitude , location.longitude , users.picture, ( 6371 * ACOS( COS( RADIANS($lat) ) * COS( RADIANS( location.latitude ) )
SELECT location.lid, location_instance.uid, users.name
, users.mail , location.latitude , location.longitude , users.picture,
( 6371 * ACOS( COS( RADIANS($lat) ) * COS( RADIANS( location.latitude ) )
* COS( RADIANS( location.longitude ) - RADIANS($lon) ) + SIN( RADIANS($lat) )
* SIN( RADIANS( location.latitude ) ) ) ) AS distance
from {location} LEFT JOIN {location_instance} ON location.lid = location_instance.lid
LEFT JOIN {users} ON location_instance.uid = users.uid WHERE MATCH (users.name)
AGAINST ('$search_term' IN BOOLEAN MODE) ORDER BY distance
但我想我首先必须在数据库中运行索引查询。请引导我成为一个不太会上网的人
编辑:
要添加全文索引的sql语句:-
alter table users add fulltext index (name);
添加索引后:-
show index from users;
你应该看到这样的东西:-
Table: users
Non_unique: 1
Key_name: name
Seq_in_index: 1
Column_name: name
Collation: NULL
Cardinality: ????
Sub_part: NULL
Packed: NULL
Null:
Index_type: FULLTEXT
Comment:
表:用户
非唯一性:1
关键字名称:名称
索引中的序号:1
列名称:名称
排序规则:空
基数:????
子部分:空
压缩:空
无效的:
索引类型:全文
评论:
要添加全文索引的sql语句:-
alter table users add fulltext index (name);
添加索引后:-
show index from users;
你应该看到这样的东西:-
Table: users
Non_unique: 1
Key_name: name
Seq_in_index: 1
Column_name: name
Collation: NULL
Cardinality: ????
Sub_part: NULL
Packed: NULL
Null:
Index_type: FULLTEXT
Comment:
表:用户
非唯一性:1
关键字名称:名称
索引中的序号:1
列名称:名称
排序规则:空
基数:????
子部分:空
压缩:空
无效的:
索引类型:全文
评论: