I am trying to find Stock of Previous Monthname.Here is my code.
PHP:
$month='April'
MYSQL Table:
Stock
Bot_Name March April
XYZ 25000 15000
SQL Query: SELECT MONTHNAME($month,INTERVAL -1 MONTH) FROM STOCK.
Expected Output:
March
25000
Above Query is not working, I had no idea where I am going wrong.Please help me out.Thanks in advance.
Why not trying something with php ?
$lastMonthName = date("F", strtotime("last month"));
$sql = "SELECT $lastMonthName FROM STOCK"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.