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
https://forums.phpfreaks.com/topic/133856-solved-the-best-way-to-write-this-sql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.