私はあなたがここでを使用する必要があると思いINNER JOINますDISTINCT:
SELECT distinct uns.*
FROM uniquestructures as uns
INNER JOIN uniqueproteins as unp on uns.ProteinID = unp.ProteinId
where LENGTH(unp.PDBASequence) < 20;
uniqueproteinsまた、列の長さを保持するためにテーブル上に別の列を作成すると、多少の喜びがあるかもしれませんPDBASequence(たとえばPDBASequenceLength)。PDBASequenceLength次に、クエリを呼び出すのではなく、列にインデックスを付けることができLENGTH(PDBASequence)ます。データが静的でない場合はPDBASequenceLength、行がテーブルに挿入または更新されるたびに列にデータを入力するトリガーを作成しuniqueproteinsます。したがって:
CREATE TRIGGER uniqueproteins_length_insert_trg
AFTER INSERT ON uniqueproteins FOR EACH ROW SET NEW.PDBASequenceLength = length(new.PDBASequence);
CREATE TRIGGER uniqueproteins_length_update_trg
AFTER UPDATE ON uniqueproteins FOR EACH ROW SET NEW.PDBASequenceLength = length(new.PDBASequence);
alter table uniqueproteins add key `uniqueproteinsIdx2` (PDBASequenceLength);
その場合、クエリは次のようになります。
SELECT uns.*
FROM uniquestructures as uns
INNER JOIN uniqueproteins as unp on uns.ProteinID = unp.ProteinId
where unp.PDBASequenceLength < 20;
幸運を!