Is it Possible to Set a Compound SQL Query with Joints and Multiple Where/And Statements on Pipedream?

This topic was automatically generated from Slack. You can find the original thread here.

Hello all! We are new to Pipedream and are looking forward to unlocking its full capabilities. It would be helpful to understand more about the mysql step as it seems somewhat restricted.

We are attempting to make a compound query which accesses multiple tables, does joins, and has multiple where/and statements. The idea is that the output be made available to a final step following the mysql step which shares a list of values from the sql query. I can share the query here if needed, but it would be helpful if this type of query is possibly to set on Pipedream. Thank you in advance!

I’d probably recommend a code step — better and more native support for writing SQL in the workflow builder is top of mind for us, we know the experience can really be improved (we feel it too)!

FYI here’s an example of a MySQL code step in a workflow I’m building:

import mysql from 'mysql2/promise'

export default defineComponent({
  props: {
    mysql: {
      type: "app",
      app: "mysql",
    },
  },
  async run({ steps, $ }) {
    const { host, port, username: user, password, database } = this.mysql.$auth

    const connection = await mysql.createConnection({
      host,
      port,
      user,
      password,
      database,
    });

    const appQuery =
      `select *
      from apps
      where id = '${steps.trigger.event.body.app_id}'`

    const [appInfo] = await connection.execute(appQuery)
    $.export('appInfo',appInfo)

    await connection.end()
  },
})

Cool. Thank you

Is there another way to do this?

Are you using a Slack action? Are you trying to pass Slack mrkdwn or an array of Blocks?

Slack action

What are you trying to send, mrkdwn or an array of Blocks?