Hello Hy,
Could you show a specific example for the following query:
> "Select * From Authors Where FirstName = ? and LastName ?"
>
The main way to create such a query is by first generating source code from
your database schema. You will then have objects such as
- Authors: This is a generated Java class of type
org.jooq.Table<AuthorsRecord>. It essentially contains generated static
objects, such as
- AUTHORS: A singleton Authors instance representing your Authors table
- FIRST_NAME/LAST_NAME: Singleton instances representing columns in your
Authors table
Using those generated artifacts, you can express a query as such:
--------------------------------------------------
String firstName = "Lukas";
String lastName = "Eder";
// Assuming that you're using MySQL...
Factory create = new Factory(connection, SQLDialect.MYSQL);
Result<AuthorsRecord> result = create.selectFrom(Authors.AUTHORS)
.where(Authors.FIRST_NAME.equal(firstName))
.and(Authors.LAST_NAME.equal(lastName))
.fetch();
--------------------------------------------------
The above query will execute as
--------------------------------------------------
select * from Authors where FirstName = ? and LastName = ?
--------------------------------------------------
and fetch the result set into the result variable. There are a couple of
different ways to achieve the same thing. The above is the easiest example.
Cheers
Lukas