3
當我嘗試將時間戳轉換下面的查詢,使用bashERROR 1582(42000)不正確的參數調用本地函數「FROM_UNIXTIME」計數
docker exec compose_TSOwncloudMySQL_1 mysql -h localhost -udockerdev -pdocker owc -e "
SELECT DATE_FORMAT(FROM_UNIXTIME(`timestamp`), '%Y%m%d timestamp%h:%i:%s') AS 'date_formatted',
oc_ldap_user_mapping.ldap_dn,
oc_activity.subject,
oc_activity.file,
oc_activity.subjectparams
FROM oc_activity INNER JOIN oc_ldap_user_mapping ON oc_activity.user = oc_ldap_user_mapping.owncloud_name
ORDER BY oc_activity.timestamp;"> /home/dockerdmz/tsowncloud/log_owc/owc_$DATE.log`
我有這樣的錯誤:
ERROR 1582 (42000) at line 2: Incorrect parameter count in the call to native function 'FROM_UNIXTIME'
當我在MySQL管理頁面運行這個查詢時,它運行良好。
SELECT DATE_FORMAT(FROM_UNIXTIME(`timestamp`), '%Y%m%d %h:%i:%s') AS 'date_formatted',
oc_ldap_user_mapping.ldap_dn,
oc_activity.subject,
oc_activity.file,
oc_activity.subjectparams
FROM oc_activity INNER JOIN oc_ldap_user_mapping ON oc_activity.user = oc_ldap_user_mapping.owncloud_name
ORDER BY oc_activity.timestamp;
當我運行此慶典代碼(無時間戳轉換),它的工作原理以及
Docker exec compose_TSOwncloudMySQL_1 mysql -h localhost -udockerdev -pdocker owc -e "
SELECT oc_activity.timestamp,
oc_ldap_user_mapping.ldap_dn,
oc_activity.subject,
oc_activity.file,
oc_activity.subjectparams
FROM oc_activity INNER JOIN oc_ldap_user_mapping ON oc_activity.user = oc_ldap_user_mapping.owncloud_name
ORDER BY oc_activity.timestamp;"> /home/dockerdmz/tsowncloud/log_owc/owc_$DATE.log
在這個語法中做'timestamp'這個詞是什麼意思''%Y%m%d timestamp%h:%i:%s'' – RiggsFolly
爲什麼你在查詢中有2個'SELECT' SELECT SELECT ' – RiggsFolly
['(反引號/反引號)在命令中是什麼意思?](http://unix.stackexchange.com/questions/27428/what-does-backquote-backtick-mean-in-commands)。 – Solarflare