SQLite - 列存在时没有这样的列

时间:2018-04-05 16:21:55

标签: sql select sqlite

我的数据库中有一个表(PRAGMA table_info(trackedinfo);),其中包含以下列(通过运行sendok获得的列)

columns of the table

问题是即使列SELECT * FROM trackedinfo WHERE sendok IS NULL; SELECT sendok FROM trackedinfo; 存在,当使用该字段在数据库上运行查询时,也会引发错误。

示例查询:

SQLITE_ERROR: SQL error or missing database (no such column: sendok)

错误:

sendok

error

但是,如果我运行查询选择所有字段,它会为我提供有关CREATE的信息:

enter image description here

以下是数据库的CREATE TABLE trackedinfo ( id INTEGER PRIMARY KEY, date_time_start TEXT, date_time_end TEXT, tracked_name TEXT, tracked_origin TEXT, tracked_maker TEXT, tracked_version TEXT, tracked_type TEXT, sendok TEXT, tracked_id TEXT ); 命令:

tracked_id

修改

.schema trackedinfo

也会发生这种情况

编辑2

我通过执行CREATE TABLE IF NOT EXISTS "trackedinfo" ("id" INTEGER PRIMARY KEY, "date_time_start" TEXT, "date_time_end" TEXT, "tracked_name" TEXT, "tracked_origin" TEXT, "tracked_maker" TEXT, "tracked_version" TEXT, "tracked_type" TEXT, "sendok " TEXT, "tracked_id " TEXT);

获得的信息
 <ul>
 <form method="post" action="{{route('matchs.payment', ['id' => $match->id,'slug' => $match->slug])}}">
@foreach($tickets as $ticket)
    <li>
        <span>{{$ticket->title}}</span> 


            <select name="ticket[{{ $ticket->title }}]">
                <option selected>0</option>
                ...
            </select>
        <span>X {{$ticket->showPrice()}}</span>
    </li>
@endforeach
<li>
    <span>TOTAL</span>
    <span>0.00€</span>
</li>
<input type="submit" value="Go To Payment Page"/>
</form>
</ul>

1 个答案:

答案 0 :(得分:0)

问题是我在列名的末尾有一个空格,通过删除这些空格来解决问题。

<强>之前:

CREATE TABLE IF NOT EXISTS "trackedinfo" ("id" INTEGER PRIMARY KEY, "date_time_start" TEXT, "date_time_end" TEXT, "tracked_name" TEXT, "tracked_origin" TEXT, "tracked_maker" TEXT, "tracked_version" TEXT, "tracked_type" TEXT, "sendok " TEXT, "tracked_id " TEXT);

<强>后:

CREATE TABLE IF NOT EXISTS "trackedinfo" ("id" INTEGER PRIMARY KEY, "date_time_start" TEXT, "date_time_end" TEXT, "tracked_name" TEXT, "tracked_origin" TEXT, "tracked_maker" TEXT, "tracked_version" TEXT, "tracked_type" TEXT, "sendok" TEXT, "tracked_id" TEXT);