Hi there, I need your appreciated help.
My tables:
- tbl_A = 8667 rows
- tbl_B = 8509 rows
- tbl_CA = 395760 rows
- tbl_CB = 9362 rows
This is query SELECT in MySQL:
SELECT
A.c_L
, CA.L_r
, CB.c_L
, DATE(CA.`start event`)
, TIME(CA.`start event`)
, CAST(CB.ntc AS UNSIGNED)
, IF(CA.clients>=0, CA.clients, 0)
, CAST(CB.ntc-IFNULL(CA.clients,0) AS UNSIGNED)
FROM tbl_A A
JOIN tbl_CA CA
ON A.c_L = CONCAT(SUBSTRING_INDEX(CA.L_r,'-',1)
,SUBSTRING_INDEX(CA.L_r,'-',-1), '')
JOIN tbl_CB CB
ON CA.L_r = CB.c_L
WHERE 1
GROUP BY
A.c_L
, CA.L_r
, CB.c_L
, DATE(CA.`start event`)
, TIME(CA.`start event`);
Output:
Affected rows: 0
Time: 64.529ms
If try this query UPDATE I have this response :
[Err] 2013 - Lost connection to MySQL server during query
Are fields is indexes in all three tables.
Can you help me?
Thanks in advance, cheers.
UPDATE
tbl_B B
, tbl_A A
JOIN tbl_CA CA
ON A.c_L = CONCAT(SUBSTRING_INDEX(CA.L_r,'-',1)
, SUBSTRING_INDEX(CA.L_r,'-',-1), '')
JOIN tbl_CB CB
ON CA.L_r = CB.c_L
SET
A.NTC = CAST(CB.ntc AS UNSIGNED)
, B.NTC = CAST(CB.ntc AS UNSIGNED)