Using 'where' => to Comparing two fields of one record against another record's two fields and if both fields of each match produce results

3 posts by 2 authors in: Forums > CMS Builder
Last Post: April 15, 2014   (RSS)

By Mikey - April 14, 2014 - edited: April 14, 2014

Can someone point me in the right direction to get this 'where' to work?

  list($our_teamRecords, $our_teamMetaData) = getRecords(array(
  'tableName'   => 'our_team',
  'where' => "first_name AND last_name = '{$property_listingsRecord['first_name']} AND {$property_listingsRecord['last_name']}'",
  'allowSearch' => false,
  ));

I need the 'where' => to apply the first_name and last_name to the records, so that if someone has the same first name OR the same last name... the 'where' => will NOT produce records for both people because the first or last names match. So it needs to be specific to the "first_name AND last_name" and only produce results based on an exact match.

For example: if John Smith has property listings and Jane Smith has property listings... only the listings associated with the individual are produced and not both John and Jane - because their last names are the same.

-OR-

if John Doe has property listings and John Smith has property listings... only the listings associated with the individual are produced and not both John Doe and John Smith - because their first names are the same.

I hope that makes sense.

Thanks for any help you can provide.

Zick

By Mikey - April 14, 2014

Okay I finally got this worked out for anyone who may find this useful...

  list($our_teamRecords, $our_teamMetaData) = getRecords(array(
  'tableName'   => 'our_team',
  'where' => "first_name = '{$property_listingsRecord['first_name']}'".' AND '."last_name = '{$property_listingsRecord['last_name']}'",
  //'loadUploads' => true,
  'allowSearch' => false,
  ));