Forum Discussion
direct query for mariadb via SQL query to join tables
Hi all,
I am new to Power BI and I am trying to get data to create a power BI report via a direct query to a Maria DB. I have two related tables that I would like to join and then import using a specialized SQL query. I could import both tables before joining but I don't feel the need to import all the data just to get rid of most of it. Here's an example simplified scenario. I have two tables posts and comments. I would like to load 1 table with the joined data, using the SQL below, rather than the two tables and then joining and processing them:
SELECT p.id, p.summary, p.view_count, IF(COUNT(c.id) > 0, 'Commented', 'Uncommented') AS status
FROM posts p
LEFT JOIN comments c
ON c.post_id = p.id
WHERE p.deleted_at IS NULL
GROUP BY p.id
I see there is a way to use an SQL query for for direct import for SQL server but I am using MariaDB. Is there a way to do this easily?
2 Replies
- AbhinavJoshi
Responsive Resident
Hi rbermanmw. Go to Power Query Editor ->New Source -> Get Data. In the source select MariaDB.
Enter the credentials
When you load the tables, you will see your SQL query in the formual section, modify that with your desired query and it should work.
- rbermanmwFrequent Visitor
AbhinavJoshi Can you show me a screenshot of the formula section with an SQL query in it?