Struggling a little bit with this, essentially I'm trying to pull some specific fields from multiple tables to form "log messages" however I'm having issues when my SQL statements become "Advanced".
Essentially what I'm looking for is:
SELECT T1.id, T2.name FROM Catalog.Table1 AS T1
LEFT OUTER JOIN Catalog.Table2 AS T2 ON T1.id = T2.id
WHERE T1.id > ?
ORDER BY T1.id ASC
Here's what I've tried:
The most basic query I can think of works fine:
SELECT * FROM table
WHERE id> ?
ORDER BY id ASC
cool, so moving forward let's try making a join:
SELECT * FROM Catalog.Table1
LEFT OUTER JOIN Catalog.Table2 ON Catalog.Table1.id = Catalog.Table2.id
WHERE Catalog.Table1.id > ?
ORDER BY Catalog.Table1.id ASC
This will result in "java.lang.IllegalStateException: Column name conflicted, please set shortnames option to false and retry"
So to alleviate this, we can either do some alias' or we can be specific and do some renames:
SELECT * FROM Catalog.Table1 AS T1
LEFT OUTER JOIN Catalog.Table2 AS T2 ON T1.id = T2.id
WHERE T1.id > ?
ORDER BY T1.id ASC
SELECT Catalog.Table1.id FROM Catalog.Table1
LEFT OUTER JOIN Catalog.Table2 ON Catalog.Table1.id = Catalog.Table2.id
WHERE Catalog.Table1.id > ?
ORDER BY Catalog.Table1.id ASC
Both of which result in "java.sql.SQLException: Parameter #1 has not been set."
I'm hoping not to create a view or a stored procedure as the DB is not mine and I don't have access.
I'd also like to avoid using Splunk Search or Datamodels to do the joins for ease of support.
Any ideas how to get this to work?
↧