How to implement a Keyword Search in MySQL?

后端 未结 7 1052
温柔的废话
温柔的废话 2020-11-29 20:25

I am new to SQL programming.

I have a table job where the fields are id, position, category, location, sala

7条回答
  •  有刺的猬
    2020-11-29 21:10

    Personally, I wouldn't use the LIKE string comparison on the ID field or any other numeric field. It doesn't make sense for a search for ID# "216" to return 16216, 21651, 3216087, 5321668..., and so on and so forth; likewise with salary.

    Also, if you want to use prepared statements to prevent SQL injections, you would use a query string like:

    SELECT * FROM job WHERE `position` LIKE CONCAT('%', ? ,'%') OR ...
    

提交回复
热议问题