I'm trying get current week, starting from monday to sunday:

select UNIX_TIMESTAMP(day), g15, g16, g17, g18, g19, g20, g21, g22, id
from tydzien where to_days(day) between
 to_days(now())- mod(to_days(now()),7)+2 /*some parameter setting a starting 
day*/ and
(to_days(now())- mod(to_days(now()),7))+8 /*ending day ^*/
order by dzien;

it works!
the table looks like this:
+------------+------+------+------+------+------+------+------+------+----+
| day        | g15  | g16  | g17  | g18  | g19  | g20  | g21  | g22  | id |
+------------+------+------+------+------+------+------+------+------+----+
| 1098128298 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |  5 |
| 1098473898 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |  9 |
| 1098560298 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 10 |
| 1098646698 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 11 |
+------------+------+------+------+------+------+------+------+------+----+

but it won't return the rows where any of columns g15, g16 etc has a value. eg

+------------+------+------+------+------+------+------+------+------+----+
| day        | g15  | g16  | g17  | g18  | g19  | g20  | g21  | g22  | id |
+------------+------+------+------+------+------+------+------+------+----+
| 1098128298 | NULL | 5561 | NULL | NULL | NULL | NULL | NULL | NULL |  9 |
| 1098473898 | NULL | NULL | NULL | 1111 | NULL | NULL | NULL | NULL | 10 |
| 1098560298 | 2355 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 11 |
+------------+------+------+------+------+------+------+------+------+----+

did i something wrong?


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to