andy666 Posted April 10, 2007 Share Posted April 10, 2007 I have two databases one has products in it one has product descriptions in it both databases use the order number as the index is it possible to merge the two so that the product description is in the correct field of the product in the product database here is an example of the two databases product database -- phpMyAdmin SQL Dump -- version 2.9.2 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Apr 10, 2007 at 03:09 PM -- Server version: 5.0.27 -- PHP Version: 5.2.1 -- -- Database: `store` -- -- -------------------------------------------------------- -- -- Table structure for table `products` -- CREATE TABLE `products` ( `Product_Category` varchar(255) default NULL, `Order_Number` varchar(255) default NULL, `Product_Name` varchar(255) default NULL, `Model_Number` varchar(255) default NULL, `Product_Manufacturer` varchar(255) default NULL, `Product_Price` double default NULL, `Current_Stock` int(11) default NULL, `Product_Descr` varchar(255) default NULL, KEY `Order_Number` (`Order_Number`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `products` -- INSERT INTO `products` (`Product_Category`, `Order_Number`, `Product_Name`, `Model_Number`, `Product_Manufacturer`, `Product_Price`, `Current_Stock`, `Product_Descr`) VALUES ('PC Components', 'BRDAB034', 'Abit IL9 Pro Socket 775 ATX', 'IL9 PRO', 'ABIT', 59, 11, NULL), ('PC Components', 'BRDAB032', 'Abit NF-M2-S SKT AM2 MATX', 'NF-M2-S', 'ABIT', 49, 46, NULL), ('PC Components', 'BRDAB031', 'Abit IP 95 SKT 775 MATX', 'IP 95', 'ABIT', 45, 61, NULL); product description database -- phpMyAdmin SQL Dump -- version 2.9.2 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Apr 10, 2007 at 03:10 PM -- Server version: 5.0.27 -- PHP Version: 5.2.1 -- -- Database: `desc` -- -- -------------------------------------------------------- -- -- Table structure for table `desc` -- CREATE TABLE `desc` ( `Order_Number` varchar(255) default NULL, `Product_Descr` varchar(255) default NULL, KEY `Order_Number` (`Order_Number`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `desc` -- INSERT INTO `desc` (`Order_Number`, `Product_Descr`) VALUES ('BRDAB034', 'Description : ATX socket 775 Motherboard ,,,,,,,,,,,,,,'), ('BRDAB034', 'Dual Core CPU support + Conroe ,,,,,,,,,,,,,,'); Quote Link to comment https://forums.phpfreaks.com/topic/46433-merge-two-databases/ Share on other sites More sharing options...
Wildbug Posted April 10, 2007 Share Posted April 10, 2007 UPDATE products JOIN desc ON products.Order_Number=desc.Order_Number SET products.Product_Descr=desc.Product_Descr -or- UPDATE products,desc SET products.Product_Descr=desc.Product_Descr WHERE products.Order_Number=desc.Order_Number Quote Link to comment https://forums.phpfreaks.com/topic/46433-merge-two-databases/#findComment-226032 Share on other sites More sharing options...
cmgmyr Posted April 10, 2007 Share Posted April 10, 2007 Your logic looks wrong to me... Why don't you have a product table where you have the item code, description...and then have an order table where you have each record pointed to a product id. I think you will find that a lot easier to manage. Quote Link to comment https://forums.phpfreaks.com/topic/46433-merge-two-databases/#findComment-226041 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.