pureDesi Posted November 22, 2006 Share Posted November 22, 2006 [code]SELECT boards.boardID, boards.title, categories.title FROM boards, categories[/code]Whenever I run this query I get double results for everything, I'm almost certain this is an easy problem, however I'm just starting to learn MySQL.Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/28033-duplicate-query-results/ Share on other sites More sharing options...
jawapro Posted November 22, 2006 Share Posted November 22, 2006 It is selecting EVERYTHING in boards for each title in categories. It is then selecting all things in boards for each title in categories. Very confusing - and hardly ever what you want.Somehow you need to join the two tables. Such as if boards has a categoriesID or something to say what category it belongs in. Also assuming that categories also has a categoriesID. Ok, so you want to select the boardID, board.title, and categories.title BUT only the category.title that matches the categoriesID in the boards table. Make any sense?[code]SELECT boards.boardID, boards.title, categories.title FROM boards, categories WHERE boards.categoriesID = categories.categoriesID[/code]Assuming thats how you link the categories, that should work. Change it as required.Hope I've been a help.JP Link to comment https://forums.phpfreaks.com/topic/28033-duplicate-query-results/#findComment-128241 Share on other sites More sharing options...
pureDesi Posted November 22, 2006 Author Share Posted November 22, 2006 Works like a charm, and not only that I now understand it. Thank you jawapro. Link to comment https://forums.phpfreaks.com/topic/28033-duplicate-query-results/#findComment-128242 Share on other sites More sharing options...
jawapro Posted November 22, 2006 Share Posted November 22, 2006 Glad I could be of assistance.I've been on boards like these asking silly questions myself plenty of times.Good luck with it all. Link to comment https://forums.phpfreaks.com/topic/28033-duplicate-query-results/#findComment-128245 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.