m1.meta_value AS roles,
    m2.meta_value AS firstname,
    m3.meta_value AS lastname,
    m4.meta_value AS mobile,
    m5.meta_value AS address1,
    m6.meta_value AS address2,
    m7.meta_value AS gender,
    m8.meta_value AS city,
    m9.meta_value AS state,
    m10.meta_value AS zipcode,
    m11.meta_value AS location,
    m12.meta_value AS syntoms
FROM wp_users u1
JOIN wp_usermeta m1 ON (m1.user_id = u1.id AND m1.meta_key = 'wp_capabilities')
JOIN wp_usermeta m2 ON (m2.user_id = u1.id AND m2.meta_key = 'first_name')
JOIN wp_usermeta m3 ON (m3.user_id = u1.id AND m3.meta_key = 'last_name')
JOIN wp_usermeta m4 ON (m4.user_id = u1.id AND m4.meta_key = 'landline')
JOIN wp_usermeta m5 ON (m5.user_id = u1.id AND m5.meta_key = 'address1')
JOIN wp_usermeta m6 ON (m6.user_id = u1.id AND m6.meta_key = 'address2')
JOIN wp_usermeta m7 ON (m7.user_id = u1.id AND m7.meta_key = 'gender')
JOIN wp_usermeta m8 ON (m8.user_id = u1.id AND m8.meta_key = 'city')
JOIN wp_usermeta m9 ON (m9.user_id = u1.id AND m9.meta_key = 'state')
JOIN wp_usermeta m10 ON (m10.user_id = u1.id AND m10.meta_key = 'zip_code')
JOIN wp_usermeta m11 ON (m11.user_id = u1.id AND m11.meta_key = 'store_location')
JOIN wp_usermeta m12 ON (m12.user_id = u1.id AND m12.meta_key = 'symptoms_id')

This Query take much more time to execute. also some time disply timeout error.

  • This is going to get all users and their meta. Is that what you want? – Jacob Peattie Sep 22 '17 at 6:19
  • i know this query result. This Query take much more time to execute so any other way to get this result fast then above query? – Rajnish Suvagiya Sep 22 '17 at 8:55
  • You don't need all of those joins - a single join will do it. But I would look into native WP functions like get_user_meta() and run that through a loop. It should be much faster. – WebElaine Sep 22 '17 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.