Monkuar Posted July 20, 2009 Share Posted July 20, 2009 here is my query that pull's up from my table "cashlogs" $result = $db->query('SELECT * FROM cashlogs ORDER By time DESC LIMIT '.$start_from.', 25') or error('Unable to fetch log info', __FILE__, __LINE__, $db->error()); Here is a screenshot on what I pull I would love it so I can pull my field imgaward from the user's table and apply them to each from_name and to_name fields in my cashlogs table. Possible? I am trying to act professional and nice as i can please help me on this what, thanks! I am asking you for help because I don't want to use WHERE Statement. because then I Would have like 250 Querys.. lol Quote Link to comment https://forums.phpfreaks.com/topic/166578-help-on-php-and-mysql/ Share on other sites More sharing options...
gizmola Posted July 20, 2009 Share Posted July 20, 2009 Certainly easy to do, but we don't know the structure of the table. What you want to do is modify the query so that it performs and inner join between cashlogs and the user table. Because you are needing to join to the cashlogs table twice, you'll need to use table aliases. In this example, I'm going to assume that the user table primary key is 'name' (again you haven't provided that info) so this is just a guess. Modify the query as needed. 'SELECT cl.*, uf.imagaward, ut.imagaward FROM cashlogs cl, user ut, user uf WHERE ut.name = cl.to_name AND uf.name = cl.from_name ORDER By time DESC LIMIT '.$start_from.' Quote Link to comment https://forums.phpfreaks.com/topic/166578-help-on-php-and-mysql/#findComment-878393 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.