Results 1 to 7 of 7
Thread: Query Union
May 25, 2010, 03:22 #1
Hello everyone, I need your help.
I have five tables in my db mysql: tbl_A, tbl_b, tbl_C, tbl_D and tbl_E and I execute this four query:
SELECT COUNT(idDTES) AS stridDTES , SUM(CL_BT_DIS) AS strCL_BT_DIS , SUM(AV) AS strAV , COUNT(SC) AS strL , COUNT(idDTES) - COUNT(SC) AS strB FROM tbl_A GROUP BY DATE_E *************** SELECT SUM(Rif_AV) AS strRif_AV , SUM(Rif_n_CL) AS strRif_n_CL FROM tbl_B *************** SELECT SUM(tbl_C.cl_BT) AS strCl_BT , COUNT(tbl_D.EVENT) AS strEVENT FROM tbl_C INNER JOIN tbl_D ON tbl_D.LINE = tbl_C.COD_LINE GROUP BY DATE_E *************** SELECT SUM(N_S_TR) AS strNSTR FROM tbl_E GROUP BY DATE_E
Any help would be very much appreciated and many thanks to any who can help me.
Thanks in advance.
May 25, 2010, 10:26 #2
- Join Date
- Aug 2007
- Kiev, Ukraine
- 0 Post(s)
- 0 Thread(s)
May 26, 2010, 06:24 #3
Many thanks x your help.
I have JOIN queries 1 and 2 and new query working, but I don't see for queries 3 and 4...:
SELECT COUNT(A.idDTES) AS stridDTES , SUM(A.CL_BT_DIS) AS strCL_BT_DIS , SUM(A.AV) AS strAV , COUNT(A.SC) AS strL , COUNT(A.idDTES) - COUNT(A.SC) AS strB , SUM(CA.Rif_AV) AS strRif_AV , SUM(CA.Rif_n_CL) AS strRif_n_CL FROM tbl_A A INNER JOIN tbl_B CA ON A.idDTES = CA.DM GROUP BY DATA_E
May 26, 2010, 06:27 #4
That's not a UNION, that's a JOIN
May 26, 2010, 06:29 #5
May 26, 2010, 06:58 #6
And how do you know what each row contains if you don't select some identifying field as well (for example DATA_E)?
May 28, 2010, 07:02 #7
Many thanks for your help, I have change method.