Farzad
04/02/2019, 1:50 PMselect *
from Orders o,
Customers c
where o.customerId = c.id
and c.id = 1234;
christophsturm
04/02/2019, 2:15 PMFarzad
04/02/2019, 2:27 PMwhere
condition and selected fields. Edited the query to something that makes more sense.Farzad
04/02/2019, 2:29 PMJoin
is because I'm working on a legacy db where tables are not designed properly which causes the join to be slower than a normal selecthho
04/02/2019, 2:37 PMselect * from foo, bar
is valid SQL and equivalent to select * from foo cross join bar
. It results in the cartesian product.hho
04/02/2019, 2:44 PMcrossJoin
to achieve what you want, but I'd recommend just rewriting your query to
SELECT *
FROM Orders o JOIN Customers c ON o.customerId=c.id
WHERE c.id = 1234;
Farzad
04/02/2019, 2:49 PMhho
04/02/2019, 2:50 PMcross join
.Farzad
04/02/2019, 3:44 PMtapac
04/02/2019, 4:00 PMclass SimpleJoin(private vararg val tables: Table) : ColumnSet() {
override val columns: List<Column<*>>
get() = tables.flatMap { it.columns }
override fun describe(s: Transaction, queryBuilder: QueryBuilder): String = tables.joinToString { it.describe(s, queryBuilder) }
override fun join(otherTable: ColumnSet, joinType: JoinType, onColumn: Expression<*>?, otherColumn: Expression<*>?, additionalConstraint: (SqlExpressionBuilder.() -> Op<Boolean>)?): Join {
TODO("not implemented")
}
override fun innerJoin(otherTable: ColumnSet): Join = TODO("not implemented")
override fun leftJoin(otherTable: ColumnSet): Join = TODO("not implemented")
override fun crossJoin(otherTable: ColumnSet): Join = TODO("not implemented")
}
tapac
04/02/2019, 4:01 PMSimpleJoin(Orders, Customers).select {
Orders.customerId eq Customers.id and (Customers.id eq 1234)
}
I didn't test that code, so please let me know if that helps