php - mySQL - Join with date range -


hi hope can me problem:

i have these tables:

games id        name 1         game1 2         game2 3         game3  plays game_id        user_id      numbers        date 1              1            2,12,34,56     2015-06-30 13:15:00 2              1            5,10,22,41     2015-06-30 13:15:00 3              1            1,7,11,34      2015-06-30 13:15:00 1              2            4,17,29,32     2015-06-30 13:15:00 1              1            2,9,19,45      2015-06-31 13:15:00 2              1            5,16,26,31     2015-06-31 13:15:00 3              1            4,12,16,34     2015-06-31 13:15:00 1              1            3,15,27,43     2015-06-01 13:15:00 1              1            1,7,14,29      2015-06-02 13:15:00 2              1            7,23,31,48     2015-06-02 13:15:00 

i need of user_id = 1 plays between today , 10 days in past if user didn't play in 1 date date should returned anyway. result should this:

game_id      user_id       numbers       date 1            1             null          2015-06-26 00:00:00 2            1             null          2015-06-26 00:00:00 3            1             null          2015-06-26 00:00:00 same days 27-28-29 1            1             2,12,34,56    2015-06-30 13:15:00 2            1             5,10,22,41    2015-06-30 13:15:00 3            1             1,7,11,34     2015-06-30 13:15:00 , on 

this query i'm using returns dates exist:

select g.id, gam.name, g.played_numbers, g.date plays g right join games gam on g.game_id = gam.id , g.user_id = 1 , g.date between '2015-05-04 15:00:00' , '2015-06-03 15:00:00' 

thanks in advance.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -