SQL help
The language of WCDB
SWIFT
e.g. Objective-C, Swift or Java
The version of WCDB
2.0.4
e.g. v1.0.5
The platform of WCDB
iOS
e.g. iOS, macOS or Android
The installation of WCDB
e.g. Cocoapods, Carthage, Maven, AAR Package or Git clone
What's the issue?
let join = Join(with: Output.tableName) .innerJoin(PublicKey.tableName).on(Output.Properties.publicKeyPath == PublicKey.Properties.path) .innerJoin(Transaction.tableName).on(Output.Properties.transactionHash == Transaction.Properties.dataHash) .leftJoin(Block.tableName).on(Transaction.Properties.blockHash == Block.Properties.headerHash) // StatementSelect let state = StatementSelect().select(Output.Properties.any.in(table: Output.tableName), PublicKey.Properties.any.in(table: PublicKey.tableName), Transaction.Properties.any.in(table: Transaction.tableName), Block.Properties.height.in(table: Block.tableName).asResultColumn().as("blockHeight")).from(join).where(Output.Properties.scriptType != ScriptType.unknown.rawValue)
SELECT transactions., transactions., transactions.*, blocks.height AS blockHeight FROM (outputs INNER JOIN publicKeys ON publicKeyPath == path INNER JOIN transactions ON transactionHash == dataHash LEFT JOIN blocks ON blockHash == headerHash) WHERE scriptType != 0
How to modify a multi-table query that returns only data from the last table in the SELECT statement?
wrong: SELECT transactions., transactions., transactions.*, blocks.height AS blockHeight FROM
Expected result:SELECT outputs., publicKeys., transactions.*, blocks.height AS blockHeight
Don't understand what you are talking about. First, you need to show me the SQL string you want to use, and then convert it to winq.
SQL I want to use: SELECT outputs.'', publicKeys."", transactions.*, blocks.height AS blockHeight
FROM outputs
INNER JOIN publicKeys ON outputs.publicKeyPath = publicKeys.path
INNER JOIN transactions ON outputs.transactionHash = transactions.dataHash
LEFT JOIN blocks ON transactions.blockHash = blocks.headerHash
WHERE outputs.scriptType != 0
There is currently a bug when using Properties.any multiple times in one statement. You can try Column(named: "*").in(table: xxx) instead. We will fix this problem in the next version.
Fixed in v2.1.0