-5
$eredmeny = mysql_query("SELECT t_nev, sum(t_ertek)
    FROM `termek_mozgas`
    WHERE datum BETWEEN NOW() - INTERVAL 30 DAY AND NOW()
        AND muv_1 = 'Beszerzés'
        OR muv_1 = 'Göngyöleg vissza'
        OR muv_1 = 'Gyártásból bejövő' group by t_nev ");

Hy! Thanks the help! My problem is my query isn't working good.

kero
  • 10,647
  • 5
  • 41
  • 51
  • What do you mean by "isn't working good"? Do you get the desired result - if not, what is it? It is hard to help you without knowing what is wrong – kero Jun 16 '14 at 22:03
  • 2
    Consider braces to ensure that your combination of AND or OR criteria are being evaluated correctly – Mark Baker Jun 16 '14 at 22:03
  • `mysql_query` has been deprecated for a while now. Stop using it, or stop expecting help with using it. – cHao Jun 17 '14 at 03:37

2 Answers2

1

Change your WHERE condition like below and also use IN operator instead of multiple chained OR condition

   WHERE datum BETWEEN NOW() - INTERVAL 30 DAY AND NOW()
   AND muv_1 IN ('Beszerzés',
                 'Göngyöleg vissza',
                 'Gyártásból bejövő')
Rahul
  • 76,197
  • 13
  • 71
  • 125
0
$eredmeny = mysql_query("SELECT t_nev, sum(t_ertek)
    FROM `termek_mozgas`
    WHERE datum BETWEEN NOW() - INTERVAL 30 DAY AND NOW()
        AND
( muv_1 = 'Beszerzés'
        OR muv_1 = 'Göngyöleg vissza'
        OR muv_1 = 'Gyártásból bejövő'
)
 group by t_nev ");
Val
  • 412
  • 4
  • 11