我正在尝试搜索卡车维护记录的MySQL数据库。我正在搜索的表是Maintenance,Truck和maintenance_parts。我需要做什么才能从Truck和Maintenance_Parts表中获取FULLTEXT分数以添加到维护表中的分数?
SELECT maintenance_id, some_id, type_code, service_date, mileage, mg_id, mg_type, comments, work_done,
MATCH(comments, work_done) AGAINST( 'valve tire' ) AS score
FROM maintenance
WHERE type_code = 'truck'
AND some_id IN (
SELECT truck_id FROM truck
WHERE MATCH( truck_number, make, model, engine, vin_number, transmission_number, comments) AGAINST( 'P' )
OR truck_number LIKE '%P%'
)
AND maintenance_id IN(
SELECT maintenance_id FROM maintenance_parts WHERE MATCH( part_num, part_desc, part_ref) AGAINST( 'valve tire' )
)
OR MATCH(comments, work_done) AGAINST( 'valve tire' )
AND status = 'A' ORDER BY score DESC LIMIT 0, 30
答案 0 :(得分:0)
您必须重写查询以消除子查询,而是使用连接来执行此操作。将子查询的全文搜索移动到父查询后,您应该能够在那里加入分数。