私は、自身に関連するテーブルを持っています。カラムはvin、type、snです。私はタイプ1の行が1つしかないタイプ2のすべての行を探したい。私はこの試みた:MySQLのWHERE EXISTSクエリで選択されたカラムを使用する
select count(*) as aggregate
from `data` as `t1`
where `type` = 2
and `last_service` < DATE_SUB(now(), INTERVAL 12 MONTH)
and exists (
select count(*) as data.count
from `data`
where count=1
and `type` = 1
)
を私は次のエラーを取得しておいてください。あなたがそのようなテーブルの列にデータを割り当てることはできません
Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '
.count from
datawhere count=1 and
type= ?)' at line 1
.
コミュニティは最近、「[緊急」の質問を追加する](http://meta.stackoverflow.com/q/326569/472495)について議論しており、企業コンセンサスはそれが受け入れられないということです。これをあなたの投稿に追加しないでください。 – halfer