0

I have two tables, one Events which contains an event start time, the other Bets contains a bet id and datetime associated with the event. I want to find how many bets were placed before the start of the event and how many after. I can use replace and substr to get the start time hour value ie 2000 (for 8pm) and the bet time of ie 2018 or 1915 which would then be a simple case of anything less than 2000 is before, anything higher is after (the concept of bets spanning into another day doesn't exist) How can I get a report that says EventId, TotalBefore, TotalAfter ? Relevant tables and columns are: Events-EventId:EventDateTime Bets-EventId:BetDateTime I know there are some left join selects in there but am struggling to work it out, any help appreciated Thanks

  • I have also encountered this exception before, and this occurs when you're trying to do some network related query on main thread. Try doing it on separate thread, and it should work. – gaurav jain Nov 28 '14 at 16:20

1 Answers1

0

Use AsyncTask to do networking in background here is one sample code.

https://stackoverflow.com/a/13172283/3225831

Community
  • 1
  • 1
user3225831
  • 477
  • 9
  • 16
  • This is relevant: https://developer.android.com/training/basics/network-ops/connecting.html It explains why you should use AsyncTask, straight from the horse's mouth. –  Nov 28 '14 at 16:32
  • Thank you all. The async approach has worked and I am a very happy bunny!! Great site, thanks again – Robert Beech Nov 28 '14 at 18:00
  • Actually I appear to have another problem, the http request works fine and database updates but my code isn't going into the if (json = null) section shown above. I want to launch another activity from there but need that criteria satisfying. Can anyone spot me doing something obviously wrong ? Thanks – Robert Beech Nov 28 '14 at 20:44
  • Make sure you getting response from you php as json. Use postman client to verify. – user3225831 Nov 28 '14 at 20:59
  • How do I add code to a comment ? I'm getting a response from json, comments after the httpget is 11-28 20:46:44.335: D/json after(1026): {"message":"Customer row successfully updated for bob,bee,gjghjjh@vhnfj.","success":1} What is postman client ? – Robert Beech Nov 29 '14 at 14:35