|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
query syntax question
i've got a form where the user can check whether a name is already in the db. At the moment, my query is:
SELECT * FROM dvdcat_director WHERE director_surname LIKE '%$searchtext%' OR director_firstname LIKE '%$searchtext%' which works perfectly if the user enters either a surname or a first name. But if the user enters the full name, no records are found. I thought that a union would be required so I tried a query like (SELECT * FROM dvdcat_director WHERE director_surname LIKE '%$searchtext%') UNION ( SELECT * FROM dvdcat_director WHERE director_firstname LIKE '%$searchtext%') but this got a parse error in php. can anyone suggest a way around this? ~magda~ |
|
#2
|
|||
|
|||
|
Here's one idea
SELECT * FROM dvdcat_director WHERE CONCAT(director_firstname, ' ',director_surname) LIKE '%$searchtext%' |
|
#3
|
|||
|
|||
|
it worked! many thanks
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > query syntax question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|