How to capture only last record of a table?

Asked

Viewed 100 times

1

The pure query (sql) below, only returns me one row of the table, it occurs that I am working with two tables (Process and Progress) and that progress has as foreign key the primary key of Process.

select fkcodprocesso, dtandamento, descricao from andamento 
order by str_to_date(dtandamento, '%d-%m-%Y') desc limit 1;

1 answer

0

You forgot to set the process table after the "from", since you are using the two table (Process and progress) you have to reference the two, it will be good:

select pc.fkcodprocesso, at.dtandamento, at.Descricao FROM processo pc, andamento at order by str_to_date(at.dtandamento, '%d-%m-%Y') desc limit 1;

  • in fact it is a report of my system, where I need to list all the processes displaying the last progress of the same, table progress. Have an idea how to do this in Codeigniter @Marco Sales?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.