-2

This is my Query . It does not give result.If i place a quote the query runs. How to place that quote.

Select sum(r.views) as sum_views ,r.revenue_date ,
l.lot_id ,l.lot_name,r.type_name 
FROM tbl_revenue_upload r , tbl_lot_details as l
WHERE  AND l.lot_id ='.$search['lot'].' 
And revenue_date >= '.$search['from_date'].'
And revenue_date <= '.$search['to_date'].'
group by r.type_id ,month(revenue_date)
krunal nerikar
  • 436
  • 4
  • 12

1 Answers1

0
'Select sum(r.revenue) as sum_revenue ,sum(r.views) as sum_views ,r.revenue_date ,l.lot_id ,l.lot_name,r.type_name 
                     FROM tbl_revenue_upload r , tbl_lot_details as l
                     WHERE r.video_id = l.video_id AND l.lot_id ='.$search['lot'].' 
                     And revenue_date >= "'.$search['from_date'].'"
                     And revenue_date <= "'.$search['to_date'].'"
                     group by r.type_id ,month(revenue_date)    
Amitesh Kumar
  • 3,051
  • 1
  • 26
  • 42
  • There is no problem with answering your own question, but please include the details regarding the changes and why you think those changes are relevant. – sjsam Aug 30 '16 at 05:50
  • And if something starts with an inverted comma, perhaps it should end with one too – Strawberry Aug 30 '16 at 06:36
  • 1
    @sjsam .The error was just too add comma " " and it worked fined – priyanka sawant Aug 31 '16 at 11:47
  • 1
    @priyankasawant Glad that this works. As I have mentioned in my comment to q, you may use prepared statements which makes your life easier. – sjsam Aug 31 '16 at 11:50