Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
rbermanmw
Frequent Visitor

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 2
AbhinavJoshi
Responsive Resident
Responsive Resident

Hi @rbermanmw. Go to Power Query Editor ->New Source -> Get Data. In the source select MariaDB. 

AbhinavJoshi_0-1689625522889.png

Enter the credentials 

AbhinavJoshi_1-1689625571239.png

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. 

 

@AbhinavJoshi Can you show me a screenshot of the formula section with an SQL query in it?

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.