Splunk doesn't seem to work with the AS operator in SQl, but rather expects you to RENAME after the query. But what do you do if the query returns the same field name in 2 dbs like this? When I try to rename off the "m.first_name" it doesnt work.
| dbquery DATABASE " SELECT m.first_name AS mFirstName,
mb.first_name AS mb_firstname
FROM DATABASE.TABLE1 m,
DATABASE.TABLE2 mb
WHERE m.id = mb.entity_id"
As some other threads, "AS alias" does not work properly status quo.
I have escaped that you do the following.
ex.
m.first_name+"" AS mFirstName, mb.first_name+"" AS mb_firstname
You can use the Advanced setting when you create your lookup and rename it in the SQL query there. Then it will return as any name you want it to. I had to do this with spaces in column names which Splunk did not know how to handle and it worked great.
As some other threads, "AS alias" does not work properly status quo.
I have escaped that you do the following.
ex.
m.first_name+"" AS mFirstName, mb.first_name+"" AS mb_firstname
Bam this worked! Thank you!
If I could use TRIM, I want you to try and TRIM
trim(m.first_name) AS mFirstName, trim(mb.first_name) AS mb_firstname
The first and last names from both tables have values when just running the query against the SQL db. When adding the suggested (AS) syntax fix to the splunk dbquery the new field names are now displayed in the results from the new search but all the first and last name fields for the renamed table return 0's and not the data from the db.
What data do you missing? Regularity or is likely something?
My environment is MySQL Server 5.5.
This returns the columns now, but doesn't return any data for those renamed columns. running in sql works fine though.