vvalter Posted September 30, 2011 Share Posted September 30, 2011 Hi I need to join two tables with different column names to query result .. Picture explains .. I have no idea what JOINing to use or what not .. Can you help me to write that query that gives me that result ? Thanks, Valter Quote Link to comment https://forums.phpfreaks.com/topic/248171-joining-two-different-tables/ Share on other sites More sharing options...
vvalter Posted September 30, 2011 Author Share Posted September 30, 2011 Cant edit first post? Anyway, the problem is if I join Table A and Table B and i get result like: A_IDA_NAMEA_AGEB_IDB_NAMEB_AGE 1JOHN10NULLNULLNULL 2JAMES30NULLNULLNULL NULLNULLNULL1JAKE20 NULLNULLNULL2JACK40 ... but that's not the right result I want result looking more like: ID NAME AGE 1JOHN10 2JAMES30 1JAKE20 2JACK40 Quote Link to comment https://forums.phpfreaks.com/topic/248171-joining-two-different-tables/#findComment-1274358 Share on other sites More sharing options...
vvalter Posted October 3, 2011 Author Share Posted October 3, 2011 Solution: SELECT a_id id, a_name name, a_age age FROM table_a UNION SELECT b_id, b_name, b_age FROM table_b; Quote Link to comment https://forums.phpfreaks.com/topic/248171-joining-two-different-tables/#findComment-1275199 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.