CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Report/Search on Mobile Phone Records with incorrect length
Pages: [1]

Author Topic: Report/Search on Mobile Phone Records with incorrect length  (Read 6898 times)

JohnFF

  • I post frequently
  • ***
  • Posts: 235
  • Karma: 6
  • CiviCRM version: 4.4.13
  • CMS version: Drupal 7.28
  • MySQL version: 5.5.31-1
  • PHP version: 5.3.27
Report/Search on Mobile Phone Records with incorrect length
August 16, 2013, 02:34:30 am
Hi guys,

What's the best way to get a list of contact records where the phone number's length is not 11 (as it should be in the UK).

Even better, is there a way of finding a list of contact records where the phone number's length is not 11 or where the first digit is not 0?

Thanks,
If you like empowering charities in a free and open way, then you're going to love Civi.

Email Amender: https://civicrm.org/extensions/email-amender
UK Phone Validator: https://civicrm.org/extensions/uk-phone-number-validator
http://civifirst.com
https://twitter.com/civifirst

JohnFF

  • I post frequently
  • ***
  • Posts: 235
  • Karma: 6
  • CiviCRM version: 4.4.13
  • CMS version: Drupal 7.28
  • MySQL version: 5.5.31-1
  • PHP version: 5.3.27
Re: Report/Search on Mobile Phone Records with incorrect length
August 19, 2013, 01:14:16 am
In case it's of use to others, here is the MySQL command I ended up using.

This is probably only of use for UK numbers, I don't know.

SELECT contact_id, first_name, last_name, phone
FROM civicrm_phone
INNER JOIN civicrm_contact on civicrm_phone.contact_id = civicrm_contact.id
WHERE (((CHAR_LENGTH(phone) != 11)
OR phone LIKE '% %')
OR SUBSTRING(phone, 1, 1)!='0')
AND phone_type_id=2;

If you like empowering charities in a free and open way, then you're going to love Civi.

Email Amender: https://civicrm.org/extensions/email-amender
UK Phone Validator: https://civicrm.org/extensions/uk-phone-number-validator
http://civifirst.com
https://twitter.com/civifirst

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Report/Search on Mobile Phone Records with incorrect length

This forum was archived on 2017-11-26.