这是我的表格
表((incrementn 4) 2)
=> 6
((incrementn -1) 3)
=> 2
BUSINESS
表BUSINESSUSERNAME|BUSINESSPASSWORD|BUSINESSNAME|
Res1 |123 |Cafe |
Res2 |456 |Foodtruck |
USER
表USERNAME|USERPASSWORD|NAME|
user1 |123 |mr.1|
user2 |234 |mr.2|
FOOD
表FOODID|FOODNAME|FOODPRICE|BUSINESSUSERNAME|
1 |CAKE | 5 |Res1 |
2 |SHAKE | 2 |Res2 |
3 |COLA | 3 |Res1 |
FOOD_RATING
我想得到这张桌子 BUSINESSUSERNAME =" Res1"
FOODREVIEWID|FOODID|FOORATING|BUSINESSUSERNAME|USERNAME|
1 |2 |3 |Res2 |user1 |
2 |2 |5 |Res2 |user2 |
3 |1 |4 |Res1 |user1 |
4 |3 |1 |Res1 |user1 |
答案 0 :(得分:1)
<强>查询强>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="content-wrapper">
<nav class="navbar navbar-default navbar-custom">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">
<img src="http://placehold.it/150x75/128236/fff?text=Logo" alt="Test Logo" />
</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#">Dropdown<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Dropdown 1</a>
</li>
<li><a href="#">Dropdown 2</a>
</li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
</div>
<div id="carousel-container">
<div id="body-carousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="http://placehold.it/2550x500/266080" alt="Chania">
</div>
<div class="item">
<img src="http://placehold.it/2550x500/266080" alt="Chania">
</div>
<div class="item">
<img src="http://placehold.it/2550x500/266080" alt="Flower">
</div>
<div class="item">
<img src="http://placehold.it/2550x500/266080" alt="Flower">
</div>
</div>
<!--Left and Right Buttons-->
<a class="left carousel-control" href="#body-carousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#body-carousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
<强>输出强>
select f.foodname, f.foodprice, avg(fr.foodrating)
from food_rating fr
inner join food f
on fr.foodid = f.foodid
group by f.foodname, f.foodprice
;
<强> sqlfiddle 强>