不正確的日期時間值:“item.purchase date”

[英]Incorrect datetime value : 'item.purchase_date'


  SELECT depreciate.id, depreciate.item_id, depreciate.batch_code,
         new_item.description, depreciate.life_time, depreciate.scrap_value,
         depreciate.dep_type, item.po_number, item.purchase_value,
         item.current_value, item.purchase_date, depreciate.annual_depreciation,
         depreciate.depreciation_rate, depreciate.total_depreciate,
         depreciate.location, depreciate.dis_id 
    FROM depreciate, item, new_item 
   WHERE depreciate.item_id=item.item_id
     AND depreciate.item_id=new_item.id
     AND new_item.data_mining=1
     AND DATE_FORMAT('item.purchase_date', '%m %d') LIKE '%09-18%'

Please if someone can tell me the error of this code ? I'm new to this.

請誰能告訴我這段代碼的錯誤?我是新手。

2 个解决方案

#1


3  

Try changing

試着改變

AND DATE_FORMAT('item.purchase_date', '%m %d') LIKE '%09-18%'

to

HAVING DATE_FORMAT(`item`.`purchase_date`, '%m %d') LIKE '%09-18%'

#2


1  

Do not use ' when you are passing column name to the DATE_FORMAT function.

當您向DATE_FORMAT函數傳遞列名時,不要使用'。

Try with:

試一試:

... AND DATE_FORMAT(item.purchase_date, '%m %d') LIKE '%09-18%'

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2012/09/18/83d7886ab8d52059a5ee8c097a8f145.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com