我在基于webSQL的Chrome扩展程序中有两个表:
第一张表:
@extends('layouts.app')
@section('content')
<!-- header logo: style can be found in header.less -->
<header class="header">
<div class="container">
<div class="row">
<div class="col-lg-6">
<a href="index.php" class="logo">
<!-- Add the class icon to your logo image or logo icon to add the margining -->
<img src="img/airbus-logo.png" />
</a></div>
<!-- Header Navbar: style can be found in header.less -->
<div class="col-lg-6">
@include('partials._userModal')
@include('partials._menu')
</div>
</div>
</div>
</header>
<div class="wrapper">
<div class="container">
<!-- Right side column. Contains the navbar and content of the page -->
<aside class="content files-list clearfix">
<h2>
@if(Auth::check())
Welcome {{ Auth::user()->fullName }}
@endif
</h2>
<div class="col-xs-5">
<h4>Change password</h4><br />
@if($errors->any())
@foreach($errors->all() as $error)
<p style='padding:15px;' class='bg-danger'>{{ $error }}</p>
@endforeach
@endif
@if(Request::get('errorMessage') !== null)
<p style='padding:15px;' class='bg-danger'>{{ Request::get('errorMessage') }}</p>
@endif
<form method="post">
{{ csrf_field() }}
<div class="placeholder">Current Password</div>
<input style="max-width:200px;" placeholder='Current password' name="oldpass" id="oldpass" class="form-control" type="password"><br>
<div class="placeholder">New password</div>
<input style="max-width:200px;" placeholder='New password' name="password" id="password" class="form-control" type="password"><br>
<div class="placeholder">Confirm password</div>
<input id="password_confirmation" style="max-width:200px;" placeholder='Confirm password' name="password_confirmation" class="form-control" type="password">
<hr>
<input type="submit" class="btn btn-primary" value="Save">
</form>
</div>
</aside>
<!-- /.right-side -->
</div>
<div style=" height: 155px;"></div>
<div id="footer">
<div class="container"> © Airbus Group 2015 </div>
</div>
</div>
<!-- ./wrapper -->
<!-- <script src="js/hub/demo.js" type="text/javascript"></script> -->
<script type="text/javascript">
$(document).ready(function(){
var bHeight = $("body").height();
var wHeight = $( window ).height();
if(bHeight < wHeight){
$("#footer").addClass("absolute");
}else{
$("#footer").removeClass("absolute");
}
if (!$.support.htmlSerialize && !$.support.opacity){
$(".placeholder").show();
}
});
</script>
@endsection
第二张表:
public function postChangePassword(Request $request)
{
$validatedData = $request->validate([
'oldpass' => 'required|min:6',
'password' => 'required|string|min:6',
'password_confirmation' => 'required|same:password',
],[
'oldpass.required' => 'Old password is required',
'oldpass.min' => 'Old password needs to have at least 6 characters',
'password.required' => 'Password is required',
'password.min' => 'Password needs to have at least 6 characters',
'password_confirmation.required' => 'Passwords do not match'
]);
$current_password = \Auth::User()->password;
if(\Hash::check($request->input('oldpass'), $current_password))
{
$user_id = \Auth::User()->id;
$obj_user = User::find($user_id);
$obj_user->password = \Hash::make($request->input('password'));
$obj_user->save();
return view('auth.passwords.changeConfirmation');
}
else
{
$data['errorMessage'] = 'Please enter correct current password';
return redirect()->route('user.getChangePassword', $data);
}
}
第一张表中的每个条目都是一个村庄。 ID的值是唯一的并且对应于同一个村庄,因此每个村庄也有一个区域,但这些表格不能(轻松)创建为一个表格,所以我已经使用了:
CREATE TABLE table1 (ID int, X int, Y int, tID int, vID int, Village varchar(50),
uID int, Player varchar(50), aID int, Alliance varchar(20), Population int)
我想获得每个区域中每个联盟的总和,因此结果类似于:
CREATE TABLE table2 (ID int, Region varchar(20))
......等等。
答案 0 :(得分:0)
试试这个
select b.region, a.alliance, sum(a.population) from
table1 a join table2 b on a.aid=b.id group by b.region, a.alliance;