Skip to content
Advertisement

Get last record from joined table

I have two tables DOCUMENT and SIGNATURES, like below

And I’m try to get last signature name.

I have a SQL FIDDLE with database and query, but when run search no record has found.

http://sqlfiddle.com/#!9/b98474/3

Here my query

Advertisement

Answer

A simple method is a correlated subquery:

With an index on signatures(doc_id, sig_id desc, signature_name) this is probably the fastest method as well.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement