【问题标题】:Selecting Data from data base SQL从数据库 SQL 中选择数据
【发布时间】:2019-02-21 01:42:52
【问题描述】:

我正在从数据库中选择一个数据,我似乎找不到错误

$check = DB::select("select * from accounts where username = ".$data['username']);

错误说明:

SQLSTATE[42S22]:未找到列:1054 中的未知列“aizen” 'where 子句' (SQL: select * from accounts where username = aizen)

【问题讨论】:

  • 请不要截取代码。只需复制粘贴即可。另外,在用户名值周围添加一些标签'。也许这会有所帮助
  • DB::select("Select * from abc where=$variable")
  • 缺少引号。
  • @Exterminator 我已经这样做了,仍然出现同样的错误

标签: php sql laravel


【解决方案1】:

试试这个

首先离开去获取数据。

$check = DB::select("select * from accounts where username = ?",[$data['username']]);

秒后获取数据。

$check = DB::select("select * from accounts where username = :userName",['userName' => $data['username']]);

【讨论】:

  • 现在修复了,谢谢
【解决方案2】:

请尝试,

$check = DB::table('table name')->where("column name",'=',"$value")->get();

【讨论】:

  • 现在修复了,谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-02
  • 2022-01-16
  • 2017-12-20
  • 2017-11-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多