Reputation: 3
I'm trying to write and automate a MySQL query that gets ingested by some downstream reporting platforms. The platform requires the CSV to have an end or record indicator (EOR) to show the last record in the document. They're wanting a dollar sign ($) to indicate the EOR and, while it's easy to manually enter that, I want to automate the report but can't seem to find a way to enter the $ in the last row, last cell. Any ideas?
Example:
First name | Last name | DOB |
---|---|---|
Mike | Smith | 1-1-1900 |
Mike | Jones | 1-1-1900 |
$ |
Upvotes: 0
Views: 92
Reputation: 13517
Just append it with a UNION ALL statement -
<YOUR_SELECT_QUERY>
UNION ALL
SELECT '$', <NULLS FOR OTHER_COLS>;
You have to use as many NULLS in your last union statement as there are columns in your first query to match the no of columns in your query.
Upvotes: 1