Good Morning... I seem to be having a problem getting the data that I want from a single query...

I have a table that contains various information on record processing
it has an auto increment field called period_id
also a field called max_pl_trans

What I need to be able to determine is the value of the max_pl_trans field in the record with the max period_id

this is what I am trying, but getting an empty set back.

SELECT max_pl_trans FROM adm_period_pay WHERE period_id=(SELECT max('period_id') FROM adm_period_pay)

Could someone give me an idea what is wrong with this query, because it makes sense to me (but that doesn't necessarilly mean anything).

thanks in advance.

Douglas

So based on your description, I think you can use this SQL query (from memory so please test it...).

SELECT * FROM adm_period_pay 
WHERE period_id = (SELECT MAX(period_id) from adm_period_pay)

[EDIT] after posting this... i realized that the sql query you posted above is basically the same..sorry i actually only read your description..didnt bother to look at your query. the problem is that you surrounded single quotes around 'period_id'.

Remove the quotes from max(period_id).

Yep, that was it... thank you both for your responses.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.