t_machine Posted November 23, 2008 Share Posted November 23, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/133856-solved-the-best-way-to-write-this-sql/ Share on other sites More sharing options...
fenway Posted November 24, 2008 Share Posted November 24, 2008 You can start by using DECIMAL and not FLOAT. Quote Link to comment https://forums.phpfreaks.com/topic/133856-solved-the-best-way-to-write-this-sql/#findComment-697862 Share on other sites More sharing options...
t_machine Posted November 26, 2008 Author Share Posted November 26, 2008 Thanks I figured out how to write the query. Sub queries saved the day. Quote Link to comment https://forums.phpfreaks.com/topic/133856-solved-the-best-way-to-write-this-sql/#findComment-699788 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.