[英]How to select one value from MySQL table row laravel
Database image数据库映像
how can i get one value from bank_id row?如何从 bank_id 行中获取一个值?
i have two table...one is bank name with id other is state with state name and bank_id(equal with bank table) state table's bank_id every row have multipal value..like 1,2,3 or 9,5,7 my question is how can i get all state name where bank id?我有两个表...一个是带有ID的银行名称,另一个是state573EZ,带有Z9ED39E2EA2EA931586B6A985A6942EF573EEF573EZ NAME和BANK_ID(BANK TABLE)问题是我怎样才能获得所有 state 名称的银行 ID?
please help me..请帮我..
mycontroler.php mycontroler.php
public function getState(Request $request)
{
$states = DB::table("states")
->where("bank_id",$request->bank_id)
->pluck("name","id");
return response()->json($states);
}
Try this尝试这个
$states = DB::table("states")
->where("bank_id",$request->bank_id)
->get();
Acording laravel documentation:根据 laravel 文档:
$states = DB::table('states')->where('bank_id', $request->bank_id)->get();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.