我有一个包含 first_name 和 last_name 的学生表。当我对名字或姓氏进行搜索时,它会为我提供正确的记录,但是当我使用全名搜索时,它不会返回任何内容。这是我的查询
SELECT
`student_personal_info`.`spi_id` AS `sid`,
`student_personal_info`.`spi_first_name` AS `fname`
FROM
`student_personal_info`
WHERE
((spi_first_name like '%test developer%') OR (spi_last_name like '%test developer%')
ORDER BY
`spi_first_name` ASC
有什么方法可以通过这两个字段组合进行搜索。
如果我们输入名字.中间名和姓氏,它将给出记录,但如果名字和姓氏不是中间名,则不获取。
SELECT `student_personal_info`.`spi_id` AS `sid` , `student_personal_info`.`spi_first_name` AS `fname`
FROM `student_personal_info`
WHERE (
spi_scholar_no LIKE '%amir hussain khan%'
)
OR (
CONCAT( spi_first_name, ' ', spi_middle_name, ' ', spi_last_name ) LIKE '%amir hussain khan%'
我也试过这个,但它只适用于完全匹配。
SELECT `student_parents_info`.`spri_spi_id` AS `sid`
FROM `student_parents_info`
WHERE (MATCH (spri_first_name, spri_middle_name, spri_last_name) AGAINST ('Pramod Kumar Sharma*' IN BOOLEAN MODE ) )
ORDER BY `spri_first_name` ASC
LIMIT 0 , 30
请提出任何其他建议。