mfallon Posted March 9, 2009 Share Posted March 9, 2009 OK so hears the situation. I have created my table with id's and values to try and simplify the DB structure but now can't work out how I run a query to get it display what I want. Here is an example. Table 1 - Users id username fav_colour_id 1 Matt 2 Table 2 - Colours id colour 1 blue 2 red 3 white I want to be able to perform a query which returns the username and the favourite colour but I'm not sure how to do this. I have spent the last few hours looking at joins and various other functions but I just can't get my head around what I need to be using. Once I can get the data outputted I can work out how to format it in my PHP website and get it to display there, I just need to work out how I get it to query at all. Quote Link to comment https://forums.phpfreaks.com/topic/148620-solved-join-union-not-really-sure-please-help/ Share on other sites More sharing options...
kickstart Posted March 9, 2009 Share Posted March 9, 2009 Hi That is a join that you require. SELECT Userid, colour FROM `Table 1` a JOIN `Table 2` b ON a.fav_colour_id = b.Coloursid All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/148620-solved-join-union-not-really-sure-please-help/#findComment-780451 Share on other sites More sharing options...
mfallon Posted March 10, 2009 Author Share Posted March 10, 2009 All sorted, on to COUNTs now which I have managed to get working in one sense, just not completely. Am putting up another post to try and sort my complex COUNT question though. Thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/148620-solved-join-union-not-really-sure-please-help/#findComment-781685 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.