Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

only last date statement in mySQL

Status
Not open for further replies.

bogtom

Programmer
Jun 11, 2001
31
US
what is wrong in this statement ? I need to get only the last modified subject from a table.



SELECT subject, date_modified FROM notes d INNER JOIN

(SELECT MAX(notes.date_modified) AS maxdate FROM notes AS mx)

ON mx.maxdate = d.date_modified



10x
 
try this:

SELECT subject, date_modified FROM notes d INNER JOIN

(SELECT MAX(notes.date_modified) AS maxdate FROM notes AS mx) AS P

ON P.maxdate = d.date_modified

-DNG
 
oops...try this

SELECT subject, date_modified FROM notes d INNER JOIN

(SELECT MAX(notes.date_modified) AS maxdate FROM notes) AS mx

ON mx.maxdate = d.date_modified

-DNg
 
10x, but it didn't works:

-------------------

SQL query:

SELECT date_modified
FROM notes d
INNER JOIN (


SELECT MAX( notes.date_modified ) AS maxdate
FROM notes
) AS mx ON mx.maxdate = d.date_modified

-----------------------------

MySQL said:

#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT MAX(notes.date_modified) AS maxdate FROM notes) AS mx
 
i wouldn't bother with anything more complex than this --
Code:
select subject
     , date_modified 
  from notes 
order 
    by date_modified desc
limit 1
:)

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top