webguync Posted May 27, 2010 Author Share Posted May 27, 2010 still getting the 3 results for every one record and an example result is... 53.466666666667 minutes AKA 00 seconds Quote Link to comment https://forums.phpfreaks.com/topic/202972-close-but-no-cigar-subtracting-the-difference-between-two-timestamp-fields/page/2/#findComment-1064274 Share on other sites More sharing options...
webguync Posted May 28, 2010 Author Share Posted May 28, 2010 any other ideas on why I can do to debug my problems? Quote Link to comment https://forums.phpfreaks.com/topic/202972-close-but-no-cigar-subtracting-the-difference-between-two-timestamp-fields/page/2/#findComment-1064455 Share on other sites More sharing options...
PFMaBiSmAd Posted May 28, 2010 Share Posted May 28, 2010 Your two queries (on the same table by the way) have nothing in them to relate the results from the first query to the second query and in fact you are re-executing the second query every time you fetch a row from the first query's result set. You need to execute ONE query that gets all the data you want and then simply loop though that data and display it. Quote Link to comment https://forums.phpfreaks.com/topic/202972-close-but-no-cigar-subtracting-the-difference-between-two-timestamp-fields/page/2/#findComment-1064456 Share on other sites More sharing options...
webguync Posted May 28, 2010 Author Share Posted May 28, 2010 that makes sense, but can I combine the two queries the way I am currently pulling the timestamp data? (SELECT TIMESTAMPDIFF) Quote Link to comment https://forums.phpfreaks.com/topic/202972-close-but-no-cigar-subtracting-the-difference-between-two-timestamp-fields/page/2/#findComment-1064467 Share on other sites More sharing options...
PFMaBiSmAd Posted May 28, 2010 Share Posted May 28, 2010 Of course you can. It's all the same data in each row. Quote Link to comment https://forums.phpfreaks.com/topic/202972-close-but-no-cigar-subtracting-the-difference-between-two-timestamp-fields/page/2/#findComment-1064469 Share on other sites More sharing options...
webguync Posted May 28, 2010 Author Share Posted May 28, 2010 can anyone provide what that query should look like? Quote Link to comment https://forums.phpfreaks.com/topic/202972-close-but-no-cigar-subtracting-the-difference-between-two-timestamp-fields/page/2/#findComment-1064681 Share on other sites More sharing options...
MadTechie Posted May 28, 2010 Share Posted May 28, 2010 I didn't expect this thread to still be going! You should be able to just use the example code on page 1 just add the extra fields in the select ie SELECT Responses.name,Answer1,Answer2,Answer3,Answer4,Answer5,Answer6,Answer7,Answer8,Answer9,Answer10,Answer11,Answer12, TIMESTAMPDIFF(SECOND,submit_timestamp,login_timestamp) as cTime FROM Responses LEFT JOIN Candidates USING (user_id) Quote Link to comment https://forums.phpfreaks.com/topic/202972-close-but-no-cigar-subtracting-the-difference-between-two-timestamp-fields/page/2/#findComment-1064695 Share on other sites More sharing options...
webguync Posted May 28, 2010 Author Share Posted May 28, 2010 thanks, will give that a try! Hopefully that will solve the problem. Quote Link to comment https://forums.phpfreaks.com/topic/202972-close-but-no-cigar-subtracting-the-difference-between-two-timestamp-fields/page/2/#findComment-1064719 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.