Tamam ben burada benim derinliği olduğumu özür dilerim. Ben bu gibi yerlerde güvenmek kişinin tür ve benim PHP geliştirmek ve doğru herhangi bir yardım değilim MySQL bilgisi büyük beğeni topluyor!
Ben wordpress sitede kayıtlı kullanıcılar hakkında bilgi toplamak için denir bu sorgu var.
$verified = $wpdb->get_results("SELECT wp_users.ID, wp_users.user_login, wp_users.user_nicename, wp_users.user_email, m1.meta_value AS first_name, m2.meta_value AS last_name, m3.meta_value AS address, m4.meta_value AS date_of_birth_ddmmyyyy, m5.meta_value AS do_you_consider_yourself_as_having_a_disability, m6.meta_value AS hearing_ability, m7.meta_value AS ethnic_origin, m8.meta_value AS sex, m9.meta_value AS mobile_number, m10.meta_value AS telephone_number, m11.meta_value AS postcode, m12.meta_value AS towncity, m13.meta_value AS county, m14.meta_value AS who_is_paying_for_the_course, m15.meta_value AS course_type, m16.meta_value AS start_date, m17.meta_value AS course_times, m18.meta_value AS duration, m19.meta_value AS venue, m20.meta_value AS price, m21.meta_value AS code
FROM wp_users
INNER JOIN wp_usermeta m ON wp_users.id = m.user_id
AND m.meta_key = 'wp_user_level'
AND m.meta_value =0
LEFT JOIN wp_usermeta m1 ON wp_users.id = m1.user_id
AND m1.meta_key = 'first_name'
LEFT JOIN wp_usermeta m2 ON wp_users.id = m2.user_id
AND m2.meta_key = 'last_name'
LEFT JOIN wp_usermeta m3 ON wp_users.id = m3.user_id
AND m3.meta_key = 'address'
LEFT JOIN wp_usermeta m4 ON wp_users.id = m4.user_id
AND m4.meta_key = 'date_of_birth_ddmmyyyy'
LEFT JOIN wp_usermeta m5 ON wp_users.id = m5.user_id
AND m5.meta_key = 'do_you_consider_yourself_as_having_a_disability'
LEFT JOIN wp_usermeta m6 ON wp_users.id = m6.user_id
AND m6.meta_key = 'hearing_ability'
LEFT JOIN wp_usermeta m7 ON wp_users.id = m7.user_id
AND m7.meta_key = 'ethnic_origin'
LEFT JOIN wp_usermeta m8 ON wp_users.id = m8.user_id
AND m8.meta_key = 'sex'
LEFT JOIN wp_usermeta m9 ON wp_users.id = m9.user_id
AND m9.meta_key = 'mobile_number'
LEFT JOIN wp_usermeta m10 ON wp_users.id = m10.user_id
AND m10.meta_key = 'telephone_number'
LEFT JOIN wp_usermeta m11 ON wp_users.id = m11.user_id
AND m11.meta_key = 'postcode'
LEFT JOIN wp_usermeta m12 ON wp_users.id = m12.user_id
AND m12.meta_key = 'towncity'
LEFT JOIN wp_usermeta m13 ON wp_users.id = m13.user_id
AND m13.meta_key = 'county'
LEFT JOIN wp_usermeta m14 ON wp_users.id = m14.user_id
AND m14.meta_key = 'who_is_paying_for_the_course'
LEFT JOIN wp_usermeta m15 ON wp_users.id = m15.user_id
AND m15.meta_key = 'course_type'
LEFT JOIN wp_usermeta m16 ON wp_users.id = m16.user_id
AND m16.meta_key = 'start_date'
LEFT JOIN wp_usermeta m17 ON wp_users.id = m17.user_id
AND m17.meta_key = 'course_times'
LEFT JOIN wp_usermeta m18 ON wp_users.id = m18.user_id
AND m18.meta_key = 'duration'
LEFT JOIN wp_usermeta m19 ON wp_users.id = m19.user_id
AND m19.meta_key = 'venue'
LEFT JOIN wp_usermeta m20 ON wp_users.id = m20.user_id
AND m20.meta_key = 'price'
LEFT JOIN wp_usermeta m21 ON wp_users.id = m21.user_id
AND m21.meta_key = 'code'
WHERE user_login NOT LIKE '%unverified__%'
ORDER BY course_type ASC");
Şimdi kendi içinde sorgu ideal olmadığını biliyoruz. Ama ne yapmak istediğiniz bir değişken veya dosya boyutunu kaydetmek istiyorsunuz başka bir yolu kullanarak ORDER BY
değerini değiştirmek olduğunu (çok sistem kaynakları?), Bu mümkün olurdu?
Örneğin ben bu ben (yanlış olsa bile) elde etmek istiyorsanız ne ise
$verified = $wpdb->get_results("SELECT wp_users.ID, wp_users.user_login, wp_users.user_nicename, wp_users.user_email, m1.meta_value AS first_name, m2.meta_value AS last_name, m3.meta_value AS address, m4.meta_value AS date_of_birth_ddmmyyyy, m5.meta_value AS do_you_consider_yourself_as_having_a_disability, m6.meta_value AS hearing_ability, m7.meta_value AS ethnic_origin, m8.meta_value AS sex, m9.meta_value AS mobile_number, m10.meta_value AS telephone_number, m11.meta_value AS postcode, m12.meta_value AS towncity, m13.meta_value AS county, m14.meta_value AS who_is_paying_for_the_course, m15.meta_value AS course_type, m16.meta_value AS start_date, m17.meta_value AS course_times, m18.meta_value AS duration, m19.meta_value AS venue, m20.meta_value AS price, m21.meta_value AS code
FROM wp_users
INNER JOIN wp_usermeta m ON wp_users.id = m.user_id
AND m.meta_key = 'wp_user_level'
AND m.meta_value =0
LEFT JOIN wp_usermeta m1 ON wp_users.id = m1.user_id
AND m1.meta_key = 'first_name'
LEFT JOIN wp_usermeta m2 ON wp_users.id = m2.user_id
AND m2.meta_key = 'last_name'
LEFT JOIN wp_usermeta m3 ON wp_users.id = m3.user_id
AND m3.meta_key = 'address'
LEFT JOIN wp_usermeta m4 ON wp_users.id = m4.user_id
AND m4.meta_key = 'date_of_birth_ddmmyyyy'
LEFT JOIN wp_usermeta m5 ON wp_users.id = m5.user_id
AND m5.meta_key = 'do_you_consider_yourself_as_having_a_disability'
LEFT JOIN wp_usermeta m6 ON wp_users.id = m6.user_id
AND m6.meta_key = 'hearing_ability'
LEFT JOIN wp_usermeta m7 ON wp_users.id = m7.user_id
AND m7.meta_key = 'ethnic_origin'
LEFT JOIN wp_usermeta m8 ON wp_users.id = m8.user_id
AND m8.meta_key = 'sex'
LEFT JOIN wp_usermeta m9 ON wp_users.id = m9.user_id
AND m9.meta_key = 'mobile_number'
LEFT JOIN wp_usermeta m10 ON wp_users.id = m10.user_id
AND m10.meta_key = 'telephone_number'
LEFT JOIN wp_usermeta m11 ON wp_users.id = m11.user_id
AND m11.meta_key = 'postcode'
LEFT JOIN wp_usermeta m12 ON wp_users.id = m12.user_id
AND m12.meta_key = 'towncity'
LEFT JOIN wp_usermeta m13 ON wp_users.id = m13.user_id
AND m13.meta_key = 'county'
LEFT JOIN wp_usermeta m14 ON wp_users.id = m14.user_id
AND m14.meta_key = 'who_is_paying_for_the_course'
LEFT JOIN wp_usermeta m15 ON wp_users.id = m15.user_id
AND m15.meta_key = 'course_type'
LEFT JOIN wp_usermeta m16 ON wp_users.id = m16.user_id
AND m16.meta_key = 'start_date'
LEFT JOIN wp_usermeta m17 ON wp_users.id = m17.user_id
AND m17.meta_key = 'course_times'
LEFT JOIN wp_usermeta m18 ON wp_users.id = m18.user_id
AND m18.meta_key = 'duration'
LEFT JOIN wp_usermeta m19 ON wp_users.id = m19.user_id
AND m19.meta_key = 'venue'
LEFT JOIN wp_usermeta m20 ON wp_users.id = m20.user_id
AND m20.meta_key = 'price'
LEFT JOIN wp_usermeta m21 ON wp_users.id = m21.user_id
AND m21.meta_key = 'code'
WHERE user_login NOT LIKE '%unverified__%'
ORDER BY " . $MYVARIABLE ."ASC");
$MYVARIABLE = 'my_order_by_column_name';
Ben bir "Madde ORDER BY" olabilir bir yerde okudum ama bu nasıl kullanılabileceğini eğer ben emin değilim??
Herhangi bir yardım çok takdir!
Craig