Jump to content

Recommended Posts

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!

 

Link to comment
https://forums.phpfreaks.com/topic/288000-gathering-data-from-two-tables/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.