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 Link to comment https://forums.phpfreaks.com/topic/211858-how-to-extract-data-from-different-types-of-tables-and-use-to-generate-reports/ 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 Link to comment https://forums.phpfreaks.com/topic/211858-how-to-extract-data-from-different-types-of-tables-and-use-to-generate-reports/#findComment-1104280 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 Link to comment https://forums.phpfreaks.com/topic/211858-how-to-extract-data-from-different-types-of-tables-and-use-to-generate-reports/#findComment-1104333 Share on other sites More sharing options...
heshan Posted August 29, 2010 Author Share Posted August 29, 2010 Thnaks a lot..... Link to comment https://forums.phpfreaks.com/topic/211858-how-to-extract-data-from-different-types-of-tables-and-use-to-generate-reports/#findComment-1104919 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.