SET and Select Query combine Run in a Single MySql Query to pass result in pentaho

prat

Below 3 queries i want to run as single query in mysql and i will pass this result to Pentaho query component to plot some graph.

SET @input = select "22:4,33:4" from dual;  
SET @count := 0;     
select SUBSTRING_INDEX(@input, ' ', (@count) * 2), ' ', -1) as xyz, som_cnt as count from abc;   

Sample string is of unknown length (22:4,33:4,96:6....)

expected output 

xyz      count
---------------- 
22        4
33        4
96        6

reference - Mysql Query to Separate space delimited String Convert into 2 columns

  • Set query count=0, If i can Merge this SET query in select query that is also ok.
  • Select query doing some parsing on input string using count - just sample substring is added. (parsing logic is added here)

I want same functionality in mysql link shown below i tried this solution but i am not sure is set_config works in mysql. SET and SELECT within a single query?

or any method to run store procedure in Query component of Pentaho.

Madhur Bhaiya

You can move the initialization of user-defined session variables to a Derived table, and Cross Join with your other table(s):

SELECT SUBSTRING_INDEX(@input, ' ', (@count) * 2), ' ', -1) AS xyz, 
       som_cnt AS `count` 
FROM abc
CROSS JOIN (SELECT @count := 0, 
                   @input := '22:4,33:4'
           ) AS user_init_vars 

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Loop the select query result set in MYSQL Stored Procedure

分類Dev

MySQL JOIN multiple query result to 1 result set

分類Dev

MySQL: Select query execution and result fetch time increases with number of connections

分類Dev

How to combine "LIKE" with "IN" in a MYSQL query?

分類Dev

MySQL Query; Combine two tables

分類Dev

Mysql: Query in Select

分類Dev

one to one result in mysql Query

分類Dev

MySQL query gives wrong result

分類Dev

Loop array in mysql query and for the result

分類Dev

Creating single query with subquery, essentially a insert query with select query

分類Dev

How to pass & symbol in MySQL query?

分類Dev

MySQL query does not run in SQLite

分類Dev

MYSQL INSERT INTO FROM SELECT QUERY

分類Dev

Looping result from SQL select query

分類Dev

store result of select query into array variable

分類Dev

SELECT query return error on Empty result

分類Dev

Add row to Firebird query result using select

分類Dev

postgres SELECT query returns unusable result

分類Dev

What is the result of a mysql SELECT query on a table already LOCKED (write) by another session?

分類Dev

SQL Select COUNT for Multiple Columns in a single Query

分類Dev

Pentaho CDE nested sql query

分類Dev

MySQL: Pivot-like query result

分類Dev

Join 2 Mysql query and result in the same

分類Dev

MySQL query prepared statement not returning any result

分類Dev

Setting $_SESSION as result from MySQL Query

分類Dev

MySQL doesn't output PHP query result

分類Dev

How to write a query to get result in mysql

分類Dev

Single MySQL query with row averages based on conditions

分類Dev

I need to combine two results from a SQL select query

Related 関連記事

ホットタグ

アーカイブ