title: MYSQL/PHP/AJAX Search using SELECT, CONCAT, OR and LIKE on multiple columns
body: <p>I'm makeing a search filed for a table that has 25+ columns in it. Two of them are a First Name and a Last name. I can get the CONCAT to search them fine alone but when I add the other OR selections I get errors. Can anyone point me in the right direction? Any help would be great.
  More details:
  I'm tring to figure this out here.. I have two different SELECT statments that are working fine #1 is </p>
  
  <pre><code>$query = "SELECT `CustomerID`, `CompanyName`, `ContactFirstName`, `ContactLastName`,
  `BillingAddress`, `BillingAddress2`, `City`, `PostalCode`, `PhoneNumber`, `FaxNumber`, `EMail`
  FROM `Customers` WHERE `CustomerID` LIKE '%".mysql_real_escape_string($search_text)."%'
  OR `CompanyName` LIKE '%".mysql_real_escape_string($search_text)."%'
  OR `ContactFirstName` LIKE '%".mysql_real_escape_string($search_text)."%'
  OR `ContactLastName` LIKE '%".mysql_real_escape_string($search_text)."%'
  OR `BillingAddress` LIKE '%".mysql_real_escape_string($search_text)."%'
  OR `BillingAddress2` LIKE '%".mysql_real_escape_string($search_text)."%'
  OR `PhoneNumber` LIKE '%".mysql_real_escape_string($search_text)."%'
  OR `EMail` LIKE '%".mysql_real_escape_string($search_text)."%'";
  </code></pre>
  
  <p>And #2 is</p>
  
  <pre><code>SELECT *, CONCAT_WS(' ',ContactFirstName,ContactLastName) AS FullName FROM `Customers` HAVING
  FullName LIKE '%".mysql_real_escape_string($search_text)."%'";
  </code></pre>
  
  <p>I've been unable to figure out how to add the second select into the first one.</p>
  
  <p>---EDIT---
  After a1ex07's post I redid the query and it's working they way I was looking for...</p>
  
  <pre><code>$query = "SELECT `CustomerID`, `CompanyName`, `ContactFirstName`, `ContactLastName`, 
  BillingAddress`, `BillingAddress2`, `City`,  `PostalCode`, `PhoneNumber`, `FaxNumber`, `EMail`
  FROM `Customers`
  WHERE `CustomerID` LIKE '%".mysql_real_escape_string($search_text)."%'
  OR `CompanyName` LIKE '%".mysql_real_escape_string($search_text)."%'
  OR `BillingAddress` LIKE '%".mysql_real_escape_string($search_text)."%'
  OR `BillingAddress2` LIKE '%".mysql_real_escape_string($search_text)."%'
  OR `City` LIKE '%".mysql_real_escape_string($search_text)."%'
  OR `PostalCode` LIKE '%".mysql_real_escape_string($search_text)."%'
  OR `PhoneNumber` LIKE '%".mysql_real_escape_string($search_text)."%'
  OR `FaxNumber` LIKE '%".mysql_real_escape_string($search_text)."%'
  OR `EMail` LIKE '%".mysql_real_escape_string($search_text)."%'
  OR CONCAT_WS(' ',ContactFirstName,ContactLastName) LIKE 
  '%".mysql_real_escape_string($search_text)."%'";
  
  $query_run = mysql_query($query);
  while ($query_row = mysql_fetch_assoc($query_run)) {
  $CustomerID = $query_row['CustomerID'];
  $CompanyName = $query_row['CompanyName'];
  $ContactFirstName = $query_row['ContactFirstName'];
  $ContactLastName = $query_row['ContactLastName'];
  $BillingAddress = $query_row['BillingAddress'];
  $BillingAddress2 = $query_row['BillingAddress2'];
  $City = $query_row['City'];
  $PostalCode = $query_row['PostalCode'];
  $PhoneNumber = $query_row['PhoneNumber'];
  $FaxNumber = $query_row['FaxNumber'];
  $EMail = $query_row['EMail'];
  
  echo $CustomerID.' '.$CompanyName.' '.$ContactFirstName.' '.$ContactLastName.'
  '.$BillingAddress.' '.$BillingAddress2.' '.$City.' '.$PostalCode.' '.$PhoneNumber.' 
  '.$FaxNumber.' '.$EMail.'&lt;br&gt;';
  </code></pre>
  
  <p>It seems to be doing what I want, unless there would be a way to get the <code>FullName</code> variable back in?</p>