I am running some SQL queries from command line as follows:
var MyCtrl = function ($scope, listService) {
console.log(listService.cars[1]);
}
myApp.controller('MyCtrl', ['$scope', 'listService', MyCtrl])
I need to print column names whether the query returns any data or not. Currently when there is no data to return, i.e when query returns an empty result set this command does not print anything.
For example my query is:
cat my_query.sql | mysql --defaults-file=my_conf.cnf
I need this query to return
-- id=-1 doesn't exist
SELECT col1, col2 FROM table WHERE id=-1
Instead it returns nothing. Is it possible to do that using purely mysql and standard unix commands?
Thanks.
答案 0 :(得分:2)
Adding a UNION ALL to a SELECT with "dummy"/blank data might work:
/bin/zless:
not a dynamic executable
I don't run queries from the command line, so this is assuming it normally would give you the column names if you had at least one row in the results.