Ideally I need a query that is equivalent to
select * from customer where row_number() = 3
but that's illegal.
I can't use an auto incremented field.
row_number() is the row that needs to be selected.
How do I go about this?
EDIT: Well, I use iSql*plus to practice, and using limit and auto_increment is illegal for some reason. I ended up creating a sequence and a trigger and just upped the id by 1 every time there was an entry.
To select rows using selection symbols for character or graphic data, use the LIKE keyword in a WHERE clause, and the underscore and percent sign as selection symbols. You can create multiple row conditions, and use the AND, OR, or IN keywords to connect the conditions.
If you want to select only specific columns, replace the * with the names of the columns, separated by commas. The following statement selects just the name_id, firstname and lastname fields from the master_name table.
In SQLJ, a single-row query can be executed and its result set data can be retrieved with a single statement: SELECT ... INTO <select target list> . The INTO-clause contains a list of host variables or host expressions that receive the result set data.
You can use LIMIT 2,1
instead of WHERE row_number() = 3
.
As the documentation explains, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return.
Keep in mind that it's an 0-based index. So, if you want the line number n, the first argument should be n-1. The second argument will always be 1, because you just want one row. For example, if you want the line number 56 of a table customer
:
SELECT * FROM customer LIMIT 55,1
You cannot select a row like that. You have to specify a field whose values will be 3
Here is a query that will work, if the field you are comparing against is id
select * from customer where `id` = 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With