0
私はかなり長い間Sqlite.Swiftで作業していましたが、私は立ち往生しています。 String
の値が "yes"または "no"の行の量だけ.count
からInt
を取得しようとしています。Sqlite.Swift:列/フィールドの値が "x"の行の数をカウントする
私は次の関数を使用して、ランダムに1回だけ(繰り返しなしで)行を選択しています。私はこれが記述された行だけのために.count
を定義するための良いスタートでなければならないと思ったが、これが可能であるかどうか全く分かりません。
func randomNumber() -> Int {
var randomNumber = Int(arc4random_uniform(UInt32(try! database.scalar(table.select(ItemId.distinct.count)))))
while pickedNumber == randomNumber {
randomNumber = Int(arc4random_uniform(UInt32(try! database.scalar(table.select(ItemId.distinct.count)))))
}
pickedNumber = randomNumber
return randomNumber
}
let randomRow = randomNumber()
感謝:
は、これは私が働いて、私の "行ランダマイザー" を得た方法です!自分の質問に答える