這是我的數據庫表,我如何查詢,以便我可以得到如下所需的輸出。我可以查詢數據庫使用單個查詢語句來獲取JSON輸出?Mysql查詢加入條件
Table name: rowManager
+-------------+-----------------+----------------+
| rowid | rowname | showid |
+-------------+-----------------+----------------+
| 1 | first | 0 |
| 17 | second | 2 |
| 18 | third | 0 |
| 20 | forth | 0 |
+-------------+-----------------+----------------+
Table name: row_vid
+-------------+----------------+-----------------+-----------------+
| rowid | name | description | submission_date |
+-------------+----------------+-----------------+-----------------+
| 1 | Learn PHP | abavavaav | 2007-05-24 |
| 17 | Learn MySQL | sdasdsa | 2007-05-24 |
| 20 | JAVA Script | Sanjay | 2007-05-06 |
| 1 | JAVA | Sanjay | 2007-05-06 |
| 18 | Android | Sanjay | 2007-05-06 |
| 17 | ios | Sanjay | 2007-05-06 |
| 1 | python | Sanjay | 2007-05-06 |
| 18 | c++ | Sanjay | 2007-05-06 |
| 18 | c# | Sanjay | 2007-05-06 |
| 17 | ruby | Sanjay | 2007-05-06 |
| 18 | JQuery | Sanjay | 2007-05-06 |
| 17 | objective c | Sanjay | 2007-05-06 |
| 1 | JAVA Tutorial | Sanjay | 2007-05-06 |
+-------------+----------------+-----------------+-----------------+
$rowQuery='SELECT * from row_vid,rowManagr where rowManagr.showid=0';
我試圖查詢這些表,使得它給了我像輸出:
{
"responses":{
"First":[
{
"name":"Learn PHP"
},
{
"name":"JAVA"
},
{
"name":"python"
},
{
"name":"JAVA Tutorial"
}
],
"Other Show":[
{
"name":"Learn MySQL"
},
{
"name":"ios"
},
{
"name":"ruby",
},
{
"name":"objective c"
}
],
"Videos":[
{
"name":"Android"
},
{
"name":"c++ "
},
{
"name":"c#",
},
{
"name":"JQuery"
}
]
}
}
感謝
我覺得你首先需要看看連接。 – Strawberry
我想但不能得到所需的輸出:( – user3294288