Reputation: 961
I've an issue with the columns result from a subquery.
When I write the query:
select Q1.numi, Q1.sir from (select numi, sir from cust_vehicle where topg = 'VU') Q1
inner join (select id_contact, sir, ni from cust_contact) Q2 on Q1.sir = Q2.sir
I get 2 output columns (numi and sir).
But if I transform the query above as a subquery like:
select Q3.*
from (
select Q1.numi, Q1.sir from (select numi, sir from cust_vehicle where topg = 'VU') Q1
inner join (select id_contact, sir, ni from cust_contact) Q2 on Q1.sir = Q2.sir
) Q3
I get only the first column as output (the numi field).
Why do I have this behaviour?
For information, I use MySQL 5.6.11 on OS X 10.8
Upvotes: 0
Views: 78
Reputation: 961
I found the origin of the problem. It's MySQL Workbench. I opened a new SQL sheet and pasted my query in it. Now, all work fine.
Thanks for your help :)
Upvotes: 1
Reputation: 33945
SELECT cv.numi
, cv.sir
, cc.id_contact
, cc.ni
FROM cust_vehicle cv
JOIN cust_contact cc
ON cc.sir = cv.sir
WHERE cv.topg = 'VU'
Upvotes: 0