Soliman
Soliman

Reputation: 441

MySQL Full Textsearch multiple fields

I have some table like this:

car/model
Audi A2 2.0 TDI
Audi A8 2.5 TDI
Audi A6 4.2 V8

From PHP I get this var: 'Audi A8'

When I run this query:

select * from cars where match(car, model) against ('Audi A8') 

MySQL returns:

Audi A2 2.0 TDI
Audi A8 2.5 TDI
Audi A6 4.2 V8

I only want 'Audi A8 2.5 TDI'. How would I do this?

Upvotes: 1

Views: 90

Answers (1)

abresas
abresas

Reputation: 835

Split the value to firstname and lastname:

$names = explode( ' ', $value );
$firstname = mysql_real_escape_string( $names[ 0 ] );
$lastname = mysql_real_escape_string( $names[ 1 ] );

and run the query:

mysql_query( "SELECT * FROM people WHERE Firstname = '$firstname' AND Lastname = '$lastname'" );

Upvotes: 1

Related Questions