enswitch_mobile_users
データをプルする方法よりも優れた方法でデータをプルする方法があると確信しています
Enswitch_User_ID、Os_Version、Phone_Type
では、どうすればこのクエリを改善および改善できますか?
$sql = "SELECT Substring(purchase.`date`,12,8) AS `Time`,
purchase.`item` AS `Package`,
Cast(Substring(purchase.`item`, 12) AS UNSIGNED) AS `Credit`,
purchase.`user` AS `Mobile_User_ID`,
(SELECT user_id FROM enswitch_mobile_users WHERE `Mobile_User_ID` = enswitch_mobile_users.`id`) AS `Enswitch_User_ID`,
(SELECT os_version FROM enswitch_mobile_users WHERE `Mobile_User_ID` = enswitch_mobile_users.`id`) AS `Os_Version`,
(SELECT phone_type FROM enswitch_mobile_users WHERE `Mobile_User_ID` = enswitch_mobile_users.`id`) AS `Phone_Type`,
(SELECT enswitch_id FROM enswitch_users WHERE `Enswitch_User_ID` = enswitch_users.`id`) AS `Enswitch_ID`
FROM (SELECT item, date, user
FROM enswitch_android_purchases
UNION
SELECT item, date, user
FROM enswitch_iphone_purchases) AS `purchase`
WHERE Substring(purchase.`date`,1,10) = :date
ORDER BY `Time` DESC";