Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
SQL link to create one table
Katieee
<p>I want to link 2 tables together through sql to use in my report. If I wanted to link the two tables up - would it be possible to do it this: if the name of T_Table exists in column 2 of table B could they be linked them up through that? (column data and table name) I know my sql and I don't think you can but I thought it was worth asking incase there actually is some kind of ninja way to do this </p>
<p> </p>
<p> </p>
<p><strong>T_Table </strong> | <strong>B Table</strong></p>
<p> | column 1 column 2</p>
<p> |</p>
<p>info | data T_Table</p>
<p>info 1 | data 1 A Table</p>
<p>info 2 | data 2 C Table</p>
Find more posts tagged with
Comments
JFreeman
<p>So you are wanting to conditionally perform a join in the query for the data set depending on the data available within a column in one of the tables?</p>
Hans_vd
<p>you could use a literal:</p>
<pre class="_prettyXprint">
WITH t_table_view AS (
SELECT 'T_Table' AS table_name,
info
FROM T_Table
)
SELECT *
FROM t_table_view
join B_Table
on (t_table_view.table_name = B_Table.column2)</pre>
Katieee
<p>@ Jesse - In answer to your question I believe so yes- I do think what Hans provided would help <br>
</p>
<p>
@Hans
Would I use all of that statement in order to get my desired results? Thank you for posting that as I didn't think it was possible
</p>
Hans_vd
<blockquote class="ipsBlockquote">Would I use all of that statement in order to get my desired results?
<p> </p>
</blockquote>
<p> </p>
<p>Not sure if I understand the question, but I think the answer is "yes" :-)</p>