Jump to content

[SOLVED] The best way to write this sql


t_machine

Recommended Posts

hi, I really hope someone can help with this problem.

 

I have two tables. One stores userid, cur_timestamp(timestamp), earn(float 8,2)

The second table has uid(this matches the userid), time_paid(timestamp), paid_amt(float 8,2)

 

Table 1.

+----+----------+---------------------+--------------+

| id  | userid      | cur_timestamp        | earn

+----+----------+---------------------+--------------+

 

Table 2.

+----+----------+---------------------+--------------+

| id  | uid          | time_paid                | paid_amt

+----+----------+---------------------+--------------+

 

 

The first table adds a row each time a userid gets a money so there will be many entry for each userid.

The second table stores each time the admin pays the userid.

What i am trying to do is write a sql query to first check if the userid in table 1 has a sum of $50 and has not been paid yet or has earned $50 or more since the last payment(which should check table 2 to see if they received a payment yet).

 

Thanks for any help on this. I do not even know where to start :(

 

 

Link to comment
Share on other sites

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.