我有这样的查询 SQL:
SELECT DISTINCT LST_KURS.LKU_ID, LST_KURS.LKU_SYMBOL FROM LST_PRODUCT_CALC join LST_KURS WHERE LST_PRODUCT_CALC.LKU_ID = LST_KURS.LKU_ID AND LST_PRODUCT_CALC.PSET_ID = #{psetId}
如何在 moor 上编写该查询?
这是我的 LST_KURS 表:
import 'package:moor/moor.dart';
class LstKurs extends Table {
@override
String get tableName => 'LST_KURS';
TextColumn get lkuId => text().named('LKU_ID')();
IntColumn get lsneId => integer().named('LSNE_ID').nullable()();
TextColumn get lkuSymbol => text().named('LKU_SYMBOL').nullable()();
@override
Set<Column> get primaryKey => {lkuId};
}
这是我的 lst_prodset_calc 表:
import 'package:moor_flutter/moor_flutter.dart';
class LstProdsetCalc extends Table {
@override
String get tableName => 'lst_prodset_calc';
IntColumn get psetId => integer()
.named('PSET_ID')
.customConstraint('NULL REFERENCES lst_prodset (PSET_ID)')();
TextColumn get lkuId => text().named('LKU_ID')();
@override
Set<Column> get primaryKey => {psetId, lkuId};
}
这是我在 Dao 中的功能:
Future<List<String>> getListKurs(int psetId) {
// idk how to write that query on moor in here
}