Mysql query returning the -help menu instead of query results

48 views Asked by At

This is the query I am using in my shell script. mysql -h 'host' -p'pass' --skip-column-names -e "select date_format('due_date', "%Y-%m-%d 23:59:59") from table_name limit 5"

When I run this I get the -help menu instead of query results. Is my syntax correct?

When I connect to Mysql and run just the query like this: select date_format('due_date', "%Y-%m-%d 23:59:59") from table_name limit 5

I get the correct result.

2

There are 2 answers

0
east.charm On

mysql -h -p --skip-column-names -e "select date_format('due_date', "%Y-%m-%d 23:59:59") from table_name limit 5"

what does the -h stand for here?

1
Keith John Hutchison On

It's probably the double quotes in your query. Try.

mysql -h 'host' -p'pass' --skip-column-names -e "select date_format('due_date', '%Y-%m-%d 23:59:59') from table_name limit 5"