Forum Discussion
How to write MySQL queries in editor query to fecth data and make visualization ?
- 9 years ago
Hi mehaboob557,
You can click Get Data -> MySQL database, then paste the query in the red section below then click OK. It will create a new table.
Best Regards,
Qiuyun Yu
Hi mehaboob557,
1. To write MySQL query join three tables with where clauses, you can refer to this sample: Multiple Table Joins with WHERE clause. As this issue is MySQL specific, please post a thread in MySQL forum to get help if you have any further question.
2. In Power BI desktop, when we get data from the MySQL table with above query in red section, it will return a separate table.
3. Sure, you can visualize data from this joined results in any visual like other table which you just select without any query specified.
Best Regards,
QiuyunYu
H v-qiuyu-msft,
Thank you for the response. I worked on mysql queries in my web project. But, in power BI, in query editor, i don't the syntax how to write.
For example, table1 , table 2 and table3 are in my data set. now i need 3 columns of table 1 and 4 columns of table 2 based on TID.
This is the editor am talking about.
If i want to do the query as below in the above editor. How can i do. If i do, it will result a new table?
SELECT `opportunities`.`id`,`opportunities`.`name`,`documents`.`id` as `doc_id`,`documents`.`document_name`,`documents`.`category_id`,`documents`.`doc_type` ,`document_revisions`.`file_ext`,`document_revisions`.`id` as `revision_id` ,`document_revisions`.`revision` FROM `opportunities`
INNER JOIN `documents_opportunities` ON `documents_opportunities`.`opportunity_id`=`opportunities`.`id`
INNER JOIN `documents` on `documents`.`id` = `documents_opportunities`.`document_id`
LEFT JOIN `document_revisions` on `document_revisions`.`document_id` = `documents`.`id`
WHERE `opportunities`.`name`='".$opportunity_name."' AND (`documents`.`category_id`='SCOPE_DOCUMENT' OR `documents`.`category_id`='PRODUCTION_DRAWING' OR `documents`.`category_id`='WORKS_CONTRACT' OR `documents`.`category_id`='WORKING_DRAWING')
AND document_revisions.id = ( SELECT id FROM document_revisions
WHERE document_revisions.document_id = documents.id ORDER BY document_revisions.revision desc LIMIT 1)Please suggest/help me to understand the query part in Power BI.
Thanks in advance.
- v-qiuyu-msft9 years ago
Community Support
Hi mehaboob557,
You can click Get Data -> MySQL database, then paste the query in the red section below then click OK. It will create a new table.
Best Regards,
Qiuyun Yu- mehaboob5579 years ago
Resolver III
Hi v-qiuyu-msft,
Thank you so much. I will try and i will accept the solution once it works for me :)
- mehaboob5579 years ago
Resolver III
Hi v-qiuyu-msft ,
I want to know, is there dynamic variable can be passed into query using Power Bi. I mean, if i am selecting any value.. that value to be passed into the query which gives a result in the visualization... is this possible ?
- Anonymous7 years agoNot applicable
Thank you so much! saved my life
- korayemzd6 years agoRegular Visitor
mehaboob557 Try this:
Source = MySQL.Database("mysqlserver", "databasename", [ReturnSingleDatabase=true, Query="select * from mytable where published=true"])