Inner Join on Two Tables

Below are the results of an inner join query linking the Customer table to the Transactions table, linking the cust_id field of the Customer table to the trans_cust_id field of the Transactions table. The results are returned in cust_id order (ascending).



cust_idtrans_cust_idcust_namecust_firstnamecust_surnametrans_grn_widgets_salestrans_blu_widgets_sales
45674567Acorn Traders LtdAntheaAdams3500.001200.00
45674567Acorn Traders LtdAntheaAdams1200.000.00
45674567Acorn Traders LtdAntheaAdams1500.004200.00
45684568Billingham's of Braithwaite LtdBertieBillingham1000.000.00
45684568Billingham's of Braithwaite LtdBertieBillingham2000.00600.00
45684568Billingham's of Braithwaite LtdBertieBillingham1500.001200.00
45704570Dimbleby PLCDianaDimbleby2000.004500.00
45704570Dimbleby PLCDianaDimbleby1500.00600.00
45704570Dimbleby PLCDianaDimbleby2000.00600.00
45714571East Empire LtdElaineEast3000.00600.00
45714571East Empire LtdElaineEast1500.001800.00
45714571East Empire LtdElaineEast2500.003600.00
45714571East Empire LtdElaineEast1500.001800.00
45724572Frannock Manor PLCFrederickFranklin2000.000.00
45724572Frannock Manor PLCFrederickFranklin2500.00600.00
45724572Frannock Manor PLCFrederickFranklin1500.001800.00
45724572Frannock Manor PLCFrederickFranklin1500.001800.00
45734573Gimley of Gosborton LtdGeorgeGimley3000.001200.00
45824582Peacock & Bradshaw LtdPeterPeacock2500.003000.00
45824582Peacock & Bradshaw LtdPeterPeacock1000.001800.00
45824582Peacock & Bradshaw LtdPeterPeacock2000.00600.00
45824582Peacock & Bradshaw LtdPeterPeacock1500.002400.00
45824582Peacock & Bradshaw LtdPeterPeacock500.002400.00
45834583Quentin's Cabins LtdQuentinQuinn500.001800.00
45834583Quentin's Cabins LtdQuentinQuinn1500.003600.00
45834583Quentin's Cabins LtdQuentinQuinn2500.00600.00
45834583Quentin's Cabins LtdQuentinQuinn500.003600.00
45834583Quentin's Cabins LtdQuentinQuinn1500.002400.00
45834583Quentin's Cabins LtdQuentinQuinn1000.002400.00
45844584Rena's Supplies LtdRenaRimshaw1000.004000.00
45854585Shenley Shovels LtdSimonSixsmith3000.003500.00
45854585Shenley Shovels LtdSimonSixsmith1000.001800.00
45854585Shenley Shovels LtdSimonSixsmith2000.002400.00
45854585Shenley Shovels LtdSimonSixsmith2000.002400.00
45854585Shenley Shovels LtdSimonSixsmith1500.002400.00
45874587United Uniforms LtdUnaUnsworth1500.00600.00
45874587United Uniforms LtdUnaUnsworth1000.002400.00
45894589Wilton's Fine Products LtdWillWilton500.000.00
45894589Wilton's Fine Products LtdWillWilton1500.00600.00
45894589Wilton's Fine Products LtdWillWilton3300.001200.00
45914591Yaxley Pies LtdYasmineYolander1000.002400.00
45924592Zimmerman's of Sawtry LtdZakZanetti1000.004800.00
46014601Irlington Industries LtdIanIcke1500.003000.00
46014601Irlington Industries LtdIanIcke1500.003550.00
46014601Irlington Industries LtdIanIcke1000.003000.00
46024602Jeff Johnston LtdJeffJohnston1000.001200.00
46024602Jeff Johnston LtdJeffJohnston1500.003000.00
46024602Jeff Johnston LtdJeffJohnston1000.003000.00
46034603Kensome & Kingston LtdKarenKensome1500.003000.00
46034603Kensome & Kingston LtdKarenKensome1500.003000.00
46034603Kensome & Kingston LtdKarenKensome1500.001800.00
46034603Kensome & Kingston LtdKarenKensome1500.001800.00
46034603Kensome & Kingston LtdKarenKensome1000.003000.00
46114611Sally's Supplies LtdSallySmithers1500.003600.00
46124612Thompson's Tents LtdTobyThompson1500.003600.00
46124612Thompson's Tents LtdTobyThompson1500.001800.00
46134613Ursula Umbridge LtdUrsulaUmbridge1500.003600.00
46144614Violet Vans LtdVioletVardy2000.001800.00
46164616X-cel LtdXariaXanda2000.003000.00
46164616X-cel LtdXariaXanda2000.001200.00
46164616X-cel LtdXariaXanda2500.00600.00
46164616X-cel LtdXariaXanda2500.002400.00
46164616X-cel LtdXariaXanda2000.001800.00
46164616X-cel LtdXariaXanda1500.001800.00
46174617Yeovil Yards LtdYusefYorke3000.003600.00
46174617Yeovil Yards LtdYusefYorke1500.003000.00
46174617Yeovil Yards LtdYusefYorke2000.002400.00
46174617Yeovil Yards LtdYusefYorke1500.001800.00
46184618Zen Products LtdZaneZellweger1000.000.00
46184618Zen Products LtdZaneZellweger1500.001800.00
46184618Zen Products LtdZaneZellweger1000.003000.00
46184618Zen Products LtdZaneZellweger2000.003400.00
MySQL Code

SELECT c.cust_id, t.trans_cust_id, c.cust_name, c.cust_firstname, c.cust_surname, t.trans_grn_widgets_sales,
t.trans_blu_widgets_sales
FROM customer AS c
INNER JOIN transactions AS t
ON c.cust_id = t.trans_cust_id
ORDER BY cust_id ASC
T-SQL (MS SQL)

SELECT c.cust_id, t.trans_cust_id, c.cust_name, c.cust_firstname, c.cust_surname,
t.trans_grn_widgets_sales, t.trans_blu_widgets_sales
FROM customer c
INNER JOIN transactions t
ON c.cust_id = t.trans_cust_id
ORDER BY cust_id ASC


Click the button below to advance to the next stage


Next: >> Inner Join on Three Tables


Or use the above 'SQL Queries' dropdown menu to jump to any stage.