OutOfInk Posted April 24, 2014 Share Posted April 24, 2014 I have two tables that relate to each other; tableA has a Columns ID, NAME, BETRESULT tableB has all the users register data; Each user places a bet on a sport for the week and they either win or lose there credits. What i wish to do is take away 20 credits from users that dont place a bet for the week. So anyone that does bet i INSERT a new row into tableA. I need to some how work out what usernames havent bet in tableA and remove 20 credits from tableB; I wrote this query but it ended up taking 20 credits off every user. SELECT bets.name, Register.SNAME FROM bets INNER JOIN Register ON bets.name = Register.SNAME If someone could help thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/288000-gathering-data-from-two-tables/ Share on other sites More sharing options...
ninedoors Posted April 25, 2014 Share Posted April 25, 2014 Try something like this: SELECT bets.name, Register.SNAME FROM Register LEFT JOIN bets ON bets.name = Register.SNAME WHERE bets.name IS NULL You will need a timestamp column in your bets table if you want to restrict it to a time frame. Quote Link to comment https://forums.phpfreaks.com/topic/288000-gathering-data-from-two-tables/#findComment-1477261 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.