heshan Posted August 27, 2010 Share Posted August 27, 2010 Hi guys, I want to generate reports and i want to use some fields of one table and other fields of another table. How can i use that? Ex. customer(customer_id, full_name,name_with_initials, address, contact_number,gender) transaction_table(tran_ID, account_number,account_type,transaction_type, amount, Date) If i want to use only customer_id, tran_ID, full_name and amount how can i use them to generate reports. I want them to be taken as fields of one table and use it.. Thanks, Heshan Quote Link to comment Share on other sites More sharing options...
Shp0ngl3 Posted August 27, 2010 Share Posted August 27, 2010 i think the best way would be to join the 2 tables into 1 query.. tizag.com has a well explained tutorial abou this http://www.tizag.com/mysqlTutorial/mysqljoins.php Regards, Shp0ngl3 Quote Link to comment Share on other sites More sharing options...
Crashthatch Posted August 27, 2010 Share Posted August 27, 2010 Assuming that the 'account_number' field in the transaction table contains the customer_id of the customer making the transaction you can use a join (read Shp0ngi5's link for more information): SELECT customer_id, tran_ID, full_name, amount FROM transaction_table LEFT JOIN customer ON transaction_table.account_number = customer.customer_id Quote Link to comment Share on other sites More sharing options...
heshan Posted August 29, 2010 Author Share Posted August 29, 2010 Thnaks a lot..... Quote Link to comment 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.