If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Simple Max row not retrieved

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-23-04, 09:36
sylviasue sylviasue is offline
Registered User
 
Join Date: Mar 2004
Location: Kuwait
Posts: 4
Simple Max row not retrieved

Hi guys

I am trying to retrieve a row of data where I am matching a foreign key and trying to get the max ID for that criteria. I get the message that the query has complete successfully but i am not getting any data.

Simple Database Structure
ID, PortID, Amount, Balance

Query
select * from t_portfolio_cash
where PortID = 32
having max(ID)

I played around and just retrieve the Max(ID) and that worked fine
Query
Select Max(ID) t_portfolio_cash
where PortID = 32

I don't understand what i am doing wrong. I really need to retrieve the entire row.

Thanks in advance
Reply With Quote
  #2 (permalink)  
Old 03-23-04, 12:21
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
Re: Simple Max row not retrieved

select * from t_portfolio_cash
where PortID = 32
order by ID desc
limit 1;
Reply With Quote
  #3 (permalink)  
Old 03-24-04, 01:19
sylviasue sylviasue is offline
Registered User
 
Join Date: Mar 2004
Location: Kuwait
Posts: 4
Re: Simple Max row not retrieved

Thanks for your help, that works fine
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On