I have the val_products table, where product id and product_value , I need to give a select * only on the line whose ID is the largest, for example I have two products with ID's 1 and 2, but I need to return in that select only the line with ID 2. I tried using max (product_id) , however it gives error if used after where.