pixeltrace Posted November 7, 2007 Share Posted November 7, 2007 i need help on my mysql statement. i want to have an output similar to the portfolio updates on this page http://mango.resonance.com.sg/ILEC/home.php wherein the property items is displayed in 3 columns. i actually have the code for the displaying in 3 columns already but my problem is i dont know how to code the sql statement for this. what i wanted to achieve is to only display the latest 3 updates for the 3 property name (macao, raffles, zayed) something like this select propety_name, property_desc from property where property name = raffles, macao, zayed order by date_created limit 1(per property_name) hope you could help me with this. thanks! Link to comment https://forums.phpfreaks.com/topic/76309-need-help-in-my-sql-statement/ Share on other sites More sharing options...
pocobueno1388 Posted November 7, 2007 Share Posted November 7, 2007 Give this query a try SELECT propety_name, property_desc FROM property WHERE property_name= 'raffles' OR property_name='macao' OR property_name='zayed' ORDER BY date_created DESC GROUP BY property_name LIMIT 3 Link to comment https://forums.phpfreaks.com/topic/76309-need-help-in-my-sql-statement/#findComment-386324 Share on other sites More sharing options...
teng84 Posted November 7, 2007 Share Posted November 7, 2007 @pixeltrace you missed IN SELECT propety_name, property_desc FROM property WHERE property_name in ('raffles' ,'macao','zayed' ) ORDER BY date_created DESC GROUP BY property_name LIMIT 3 Link to comment https://forums.phpfreaks.com/topic/76309-need-help-in-my-sql-statement/#findComment-386328 Share on other sites More sharing options...
pixeltrace Posted November 7, 2007 Author Share Posted November 7, 2007 its workng i just removed the group by from the string. thanks! Link to comment https://forums.phpfreaks.com/topic/76309-need-help-in-my-sql-statement/#findComment-386358 Share on other sites More sharing options...
pocobueno1388 Posted November 7, 2007 Share Posted November 7, 2007 If you remove the GROUP BY it's going to return the last 3 property_name's regardless if it has already displayed that property name already. Don't forget to press solved if you have it working how you want Link to comment https://forums.phpfreaks.com/topic/76309-need-help-in-my-sql-statement/#findComment-386362 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.