
February 23rd, 2013, 09:54 PM
|
|
Registered User
|
|
Join Date: Feb 2013
Posts: 11
Time spent in forums: 2 h 21 m 13 sec
Reputation Power: 0
|
|
Merging/Moving Column from T1 to T2
I am not a pro at MySql. Having spent last few days trying to make it work I think I may need a bit of help.
Two tables. Form submission date is in T1. T1 has 5 columns. T2 has 8 columns, and contains all other data. FormId column is common between the two tables. I need to move DateSubmitted column from T1 to T2 and then run SELECT query on resulting combined columns to display the data from now combined T1 & T2 tables. I cannot figure out how to move DateSubmitted column from T1 to T2 and then run SELECT query on resulting dataset. I tried UNION and JOIN suggestions I found here and on other forums but without success. Need help with constructing working query please!
SELECT query for T2:
SELECT
SubmissionId,
FieldName,
FieldValue
FROM
#__submission_values
WHERE
FormId = 6
AND
FieldName IN ('field1','field2','field3','field4','field5','field6')
ORDER BY SubmissionId ASC
and this was also suggested, it runs but DateSubmitted is not displaying:
SELECT t2.SubmissionId,
t2.FieldName,
t2.FieldValue,
t1.DateSubmitted
FROM table2 t2 INNER JOIN
table1 t1 ON t2.FormId = t1.FormId
WHERE t2.FormId = 6 AND
t2.FieldName IN ('field1','field2','field3','field4','field5','DateSubmitted')
ORDER BY t2.SubmissionId
Thanks.
|