Jump to content

jagdish kothapalle

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Posts posted by jagdish kothapalle

  1. 1. For the query,

     

    $qry  = "SELECT * FROM `products` where price > avg(price)"

     

    try the below one

     

    $qry  = "SELECT * FROM products where price > (select avg(price) from products)"

     

    The mysql engine doesn't understand avg(price) unless you have a variable something like $avgprice (which is already assigned)  passed from your php.

     

    2. Ideally, you can use multiple fields in group by clause provided they are also present in the select clause.

  2. Hi,

     

    To make it on an illustrative note, you have to convert into timestamp to calculate the difference.

     

    time() function is a php function which gives the current timestamp

     

    unix_timestamp(date) gives you the timestamp of your stored date.

     

    You can use these two timestamp variables in php to calculate the difference which will be in seconds

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.