0

I have a string which is like

"Ford Mustang 1976"

I want to look this up in a database and need to catch all 3 fields. My database structure is "Make", "Model" and "YearBuilt"

How can I do a mysql query to find this row?

kiwis
  • 30
  • 4
  • Can you control how the string is built? I'd use a ` – chris85 Sep 28 '16 at 21:53
  • You could use `concat`, http://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_concat, `select * from table where concat(make, ' ', model, ' ', year) = ?`. This requires the string matches exactly though... `1976 Ford Mustang` would fail, as would `Ford 1976 Mustang`. – chris85 Sep 28 '16 at 21:56
  • I should have added Sometimes string will have an empty year or make etc – kiwis Sep 28 '16 at 22:04

0 Answers0