php - Select the row which have variables in the text field -


i have mysql table text field, lets field name car. car's type text. have variables name, product number, date, description, address, price, etc.

now want select table, row have variables found in car field value.

for example, want find row match variables, , if car text following , if variables name = honda, product number = 4222, date = 20131223, description = cool, address = street 59, price = 15000.

<category>compact car <name>honda xxx <colour>black <productnumber>4222 <date>20131223 <code>us <description>very cool <address>street 59 <price>15000 // ... 

then mysql query output row. , second variant, output similar rows have 1 variable not match, example if price not match fine.

i not sure how mysql; maybe knows , can help.

i think work first variant.

select * car car "%name%" , car "%productnumber%" , .... 

maybe knows better, faster way. example, following better?

select locate("name", car) , locate("productnumber", car) 

i must not split car column several colums, condition

you definitely want split car column several columns (one each piece of information). query become straightforward, example:

select * _table name = 'honda' , product_number = 4222 ... 

... given constaint, this:

select * _table     car '<name>honda xxx' ,     car '<productnumber>4222' ... 

if use prepared statements, might want use template query instead:

...     car concat ('<name>', ?) ,     car concat('<productnumber>', ?)... 

but allow me insist: if application meant go in production, , if planning serve more handful of users, or if there more handful of records in table, tell whoever in charge structure very, very poor. no index can used, , become unusable soon.


Comments