How to capture only the last record of a table?

1

The pure query (sql) below, I only return one row of the table, it happens that I'm working with two tables (Process and Progress) and tempo is the primary key of Process.

select fkcodprocesso, dtandamento, descricao from andamento 
order by str_to_date(dtandamento, '%d-%m-%Y') desc limit 1;
    
asked by anonymous 14.05.2018 / 22:46

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 nice to make the tables easier for you to do:

select pc.fkcodprocesso, at.dtandamento, at.descricao FROM process pc, progress at order by str_to_date (at.dtandamento, '% d-% m-% Y') desc limit 1;

    
14.05.2018 / 23:19