e1seix Posted August 29, 2007 Share Posted August 29, 2007 I have searched this subject on the forum which returned many results, but I'm finding it very difficult to relate this to my scenario. Can you help please? I have 6 tables in my database: fragrances, skincare, shaving, bodycare, hairacre, suncare. within these tables they all have the same columns: eg. Brand, ProdTitle, Price etc. How do I link these tables together in order to produce a result whereby if the brand "LOVELY COMPANY" was 'searched' it will return results (Brand, ProdTitle, Price) under all 6 table categories where "LOVELY COMPANY" equals the brand? Am I making this clear enough? It makes sense in my head. lol Regards, Quote Link to comment https://forums.phpfreaks.com/topic/67220-linking-tables-enquiry/ Share on other sites More sharing options...
mcmuney Posted August 29, 2007 Share Posted August 29, 2007 Why don't you merge the 6 tables into 1 and add a new field and call it "type", which can represent fragrance, skincare, shaving, etc. This would also simplify what you're trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/67220-linking-tables-enquiry/#findComment-337178 Share on other sites More sharing options...
e1seix Posted August 29, 2007 Author Share Posted August 29, 2007 I could do that yes, but I'm using a phpadmin tool online and I don't believe you can swap or merge tables together once they have been created. And I'm too far into uploading table entries to start over. I do see your point of view though. lol Quote Link to comment https://forums.phpfreaks.com/topic/67220-linking-tables-enquiry/#findComment-337181 Share on other sites More sharing options...
mcmuney Posted August 29, 2007 Share Posted August 29, 2007 I think this will save you more time down the line. I'd do the following: -export the data from the 6 tables into Excel -add the type in the INSERT line codes in Excel (you can do it easily with formulas) -create new table -import SQL -if all works, delete the 6 tables Quote Link to comment https://forums.phpfreaks.com/topic/67220-linking-tables-enquiry/#findComment-337187 Share on other sites More sharing options...
e1seix Posted August 29, 2007 Author Share Posted August 29, 2007 let's say i don't choose to go this root. what kind of approach could i use to link these tables... for instance? would i have to specify every single column from each table? Quote Link to comment https://forums.phpfreaks.com/topic/67220-linking-tables-enquiry/#findComment-337190 Share on other sites More sharing options...
Jessica Posted August 29, 2007 Share Posted August 29, 2007 $sql = "SELECT table1.*, table2.*, table3.* FROM table1, table2, table3 WHERE table1.brand = 'brand here' AND table2.brand' = 'brand here' AND table3.brand = 'brand here'" Quote Link to comment https://forums.phpfreaks.com/topic/67220-linking-tables-enquiry/#findComment-337194 Share on other sites More sharing options...
e1seix Posted August 29, 2007 Author Share Posted August 29, 2007 thank you thank you thank you! Quote Link to comment https://forums.phpfreaks.com/topic/67220-linking-tables-enquiry/#findComment-337201 Share on other sites More sharing options...
e1seix Posted August 29, 2007 Author Share Posted August 29, 2007 actually one more problem. it now comes up with an error: Warning: mysql_query() [function.mysql-query]: Unable to save result set in /home/dogfight/public_html/untitled.php on line 74 MySQL client ran out of memory How to solve? Quote Link to comment https://forums.phpfreaks.com/topic/67220-linking-tables-enquiry/#findComment-337224 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.