Example mysql query statement function to select specific columns with a where clause from a table. Couldn't find any examples of MySQL queries using the autocode api when I wanted so made some simple examples.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
// change table and column name values accordingly
async function selectSpecificColumns(values) {
let query = await lib.mysql.db['@0.2.1'].query({
query: 'SELECT `column_2`, `column_4`, `column_3` FROM `table_name` WHERE `column_1` = ? OR `column_1` = ?',
values: values
});
return query
};
// values you want to check the WHERE clause against
let values = ['value_1','value_2'];
// execute
await selectSpecificColumns(values);