I have this query which returns some data:
select
id, name, username, email, password,
first_name, last_name, usertype,
block, sendemail, registerDate, lastvisitDate,
activation, params, uuid
from
jml2_users
where
uuid in ('51840915-e570-430d-9911-7247d076f6e7', '51912193-6694-4ca5-94c9-9f31d076f6e7',
'51927ada-6370-4433-8a06-30d2d076f6e7', '51c05ad7-d1d0-4eb6-bc6b-424bd076f6e7',
'd047adf1-a6af-891e-94a2d0b225dcd1b6', '2aba38f2-d7a7-0a7a-eff2be3440e3b763')
and the other query is this
SELECT
ct.TrainingID, ct.UserID, ct.TrainingType, ct.TrainingStatus,
ct.TrainingScore, ct.TrainingDate,
dbo.fn_StripCharacters(ctt.product_type,'^a-z0-9') as product_type,
ctt.product_type as oldName
FROM
clientTraining as ct
INNER JOIN
clientTraningTypes as ctt ON ct.TrainingType = ctt.TypeID
WHERE
1=1
AND UserID IN ('51840915-e570-430d-9911-7247d076f6e7', '51927ada-6370-4433-8a06-30d2d076f6e7')
AND TrainingType IN (SELECT TypeID
FROM complaincetestlinks
WHERE parent_client_id = 1039
AND isactive = 1 AND isdeleted = 0)
Both queries return different results, with userid and uuid in both tables have same data, I mean we can do a join, but the problem is: I want the second query data which are rows should be converted to columns in the new query and the data should be copied to new query with a join to the second query based on userid and uuid
I am noob at SQL and first question comes to me how do I convert the first query row data to columns and populate it with data because the first query has 5 rows. So eventually I need 5*4 = 20 columns for the new query and the data to be passed and uploaded to the new query from the second query
Not sure what I need to do here, I am lost