Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

how do we pass certain characters to a sql input and then fetch the data according to the the characters passed?

 
Labels (2)
10 Replies
Anonymous
Not applicable
Author

Hello,

Could you please elaborate your case with an example with input and expected output values?

Best regards

Sabrina

Anonymous
Not applicable
Author

yes, my input is set of alphabets, i have to pass these alphabets to a
certain column in a table in sql db and according to these alphabets i want
filter the table and fetch the data.
Anonymous
Not applicable
Author

I think you can do something like this,

0683p000009Lu2c.png

 

So assuming that your input contains a single column with the alphabets values, you can reference it in the tMysqlInput Component as shown above (row1.alphabet in the screenshot).

If your output is a file, make sure to select the append option so that you can consolidate the filters.

 

Alternatively you can always do a inner join by having the alphabets as your lookup table. This approach would be easier I think.

 

Hope you found this helpful.

Anonymous
Not applicable
Author

hi,
for example my a,b,c,d isthe characters i want to pass through mysqlinput
where the table contains set of names,salary,dept,etc.I want to get the
data of names starting with letters a,b,c,d. Can any1 suggest a better
answer?
TRF
Champion II
Champion II

You can store the "where" clause in a global variable and construct the content of this variable based on your business logic.

Then, in the tMysqlInput, concatenate the variable to the select, giving, not a sql dynamic query (from database point of view), but a query constructed dynamicaly.

Does this helps?

Anonymous
Not applicable
Author

You can use a regex in your SQL expression to filter out the data that your require.

I know it's the same design as before, but it's one of the easiest ways to do this.

0683p000009Lsw7.png0683p000009Lu2h.png0683p000009Lu2r.png

 

You can replace the fixed flow component with an input component based on whether it comes from a file or a database.

 

 

Anonymous
Not applicable
Author

but do i need to give global variable in the sql query?
Anonymous
Not applicable
Author

Yes. That's one way to do it. Or you can use a tFilterRow or tmap after the sql component and filter the data there.

You could use something like row2.Names.matches((String)globalMap.get("row1.alphabet")+"*") as the filter condition.

Anonymous
Not applicable
Author

can i just iterate these characters to my sql input and then write a query
in the mysqlinput querybox giving a like function in where clause like
[where row1.names like "'+(string)globalMap.get(row1.alphabet)+'%"], this
should work right?