community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
SOLVED

Updating a SQL Query from an output, is this possible?

Meteor

So I don't know if this is possible...but figured it would be worth asking. The top data set I am creating a unique key with the formula tool. I then would like to use those new values (unique key generated) and somehow auto insert those unique key's created and only pull those back with my 2nd data set that is joined below and then using the join tool only produce the ID found in both data sets. 

 

Is this possible?

 

 

dberroth_0-1572293882581.png

Meteor

I forgot to mention, I then would like to take these results after the join is successful, have an output created, but then take those results and join them to another table for further results

Quasar

Hi @dberroth ,

With Alteryx  you can run and  test  each step  or  after you add  a new tool  and continue after  making sure the result is good. 

Same output  can be used as input  to multiple tools .  The data  for  writing  output file  can also become input to another join . 

benakesh_0-1572296039898.png

Meteor

Thanks for the info, I guess my question still remains though if I can take the new "uniquekey" value that is created by dataset1 formula,  and somehow have those values automatically "entered" into the SQL(for dataset2) as the dataset criteria for what to pull in to then join those unique values for the output.

 

 

Highlighted
Quasar

Hi @dberroth ,

You can  move   data  into database   via in-db  'data stream in'   tool . I don't  think there is  an automatic  way to do this .   

https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/FAQ-How-Do-the-In-Database-tools-Wo...

Alteryx Certified Partner

Hi @dberroth 

 

As @benakesh mentioned, In-DB is probably the easiest way to go. However, if that's not an approach you can use for whatever the reason, the other option would be to use the Dynamic Input tool.

image.png

The template query (within the Dynamic Input tool) would be setup something like...

 

SELECT *

FROM mytable

WHERE UniqueID IN('placeholder')

 

Next, you'd select the "Modify SQL Query" option and "Add" the option to "SQL: Update WHERE clause and configuring it to replace your "placeholder" string with the concatenated string.

 

One to watch out for though... there could be a limit to how long an IN statement can be. There's a setting that, by default, will cut it off at 1000 characters, which you can adjust. if the concatenated string is over that value, it'll prepare another query for execution with the next set of characters, however, it may have cut a value in the middle.

 

I know there's plenty of articles and posts around Community that talks about this in more detail in case you're still getting stuck.

 

Hope this helps!

Jimmy
Teknion Data Solutions

Labels