我正在学习angularjs并遵循教程 - 来自这里
这是我的index.jsp -
<!doctype html>
<html lang="en" ng-app="phoneCatApp">
<head>
<title>Angular Example</title>
<script type="text/javascript" src="angular/angular.min.js"></script>
<script type="text/javascript" src="app/js/controllers.js"></script>
</head>
<body ng-controller="phoneListCtrl">
Search : -
<input ng-model="query"/> Sort by:
<select ng-model="orderProp">
<option value="name">Alphabetical</option>
<option value="age">Newest</option>
<option value="-age">Oldest</option>
</select>
<p>Total number of phones: {{phones.length}}</p>
<ul>
<li ng-repeat="phone in phones | filter:query | orderBy:orderProp"><span>{{phone.name}}</span>
<p>{{phone.snippet}}</p></li>
</ul>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这个版本的controller.js有效 -
var phonecatApp = angular.module('phoneCatApp', []);
phonecatApp.controller('phoneListCtrlOld', function($scope) {
$scope.phones = [ {
'name' : 'Nexus S',
'snippet' : 'Fast just got …
Run Code Online (Sandbox Code Playgroud) 我在mysql中有以下2个表
1. Table-Name a
id int auto-increment PK
name varchar not null
year int(4) not null
2. Table-Name b
id int auto-increment PK
term varchar not null
a_id int FK references a.id
year int(4) not null
Run Code Online (Sandbox Code Playgroud)
1.数据如下
选择*来自a;
1,'Ravi',2010
2,'Kumar',2011
Run Code Online (Sandbox Code Playgroud)
select*from b;
1,'a',1,2009
2,'b',1,2010
3,'c',1,2008
4,'d',2,2008
5,'e',2,2009
6,'f',2,2010
Run Code Online (Sandbox Code Playgroud)
现在我写了一个结果集的查询,它应该返回a.id并计算(b.id)如果b表有a.id和a.year = b.year的记录
例如 -
id | cnt
------------
1 | 1
2 | 0
------------
Run Code Online (Sandbox Code Playgroud)
这是我的查询 -
select a.id,count(b.id) cnt from a
left join b
on b.a_id=a.id
where a.year=b.year
group by …
Run Code Online (Sandbox Code Playgroud)