Combine Multiple Query Results in MySQL (by column)?

The best you can do is a UNION or UNION ALL but this requires them to have the same type and number of columns. For example: SELECT 'Customer' AS type, id, name FROM customer UNION ALL SELECT 'Supplier', id, name FROM supplier UNION ALL SELECT 'Employee', id, full_name FROM employee The column names don't have to match. The aliases from the first part will be used for the rest I'll also add that instead of: select cls.

* from (calls as cls inner join calls_users as clsusr on cls. Id=clsusr. Call_id) inner join users as usr on usr.Id=cls.

Assigned_user_id where cls. Assigned_user_id='seed_max_id you should remove the unnecessary subquery and just do: SELECT c. * FROM calls c JOIN calls_users cu ONc.

Id = cu. Call_id WHERE c. Assigned_user_id = 'seed_max_id There's no need for the extra complexity and the above is eminently more readable.

The best you can do is a UNION or UNION ALL but this requires them to have the same type and number of columns. For example: SELECT 'Customer' AS type, id, name FROM customer UNION ALL SELECT 'Supplier', id, name FROM supplier UNION ALL SELECT 'Employee', id, full_name FROM employee The column names don't have to match. The aliases from the first part will be used for the rest.

I'll also add that instead of: select cls. * from (calls as cls inner join calls_users as clsusr on cls. Id=clsusr.

Call_id) inner join users as usr on usr. Id=cls. Assigned_user_id where cls.

Assigned_user_id='seed_max_id' you should remove the unnecessary subquery and just do: SELECT c. * FROM calls c JOIN calls_users cu ONc. Id = cu.

Call_id WHERE c. Assigned_user_id = 'seed_max_id' There's no need for the extra complexity and the above is eminently more readable.

This can't be done in UNION, because I need to combine columns of the queries. – Imrul Jan 24 '10 at 12:25.

I assume you want your example to return a single row combining the corresponding entries from all these tables. Try this and tell us if it worked: select * from users as usr left outer join (calls as cls inner join calls_users as clsusr on cls. Id = clsusr.

Call_id) on usr. Id = cls. Assigned_user_id left outer join (meetings as mtn inner join meetings_users as mtnusr on mtn.Id = mtnusr.

Meeting_id) on usr. Id = mtn. Assigned_user_id left outer join tasks as tsk on usr.

Id = tsk. Assigned_user_id left outer join (notes as nts inner join accounts as acnts on acnts.Id=nts. Parent_id) on usr.

Id = acnts. Assigned_user_id where user. Id = 'seed_max_id.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions