Jump to content

[SOLVED] New to MySQL and need to get other columns information based on newest post.


aschulz90

Recommended Posts

Hi, I am making a page (or trying to) that would enable users to view the newest agenda for each board in our local government. I can do that for the most part (I'm really starting to like php), but my problem is:

 

I would like to be able to post only the content of the newest row on a table. (there will be one table per board/commitee/commission)

I know how to do:

$query = "SELECT max(Uploaded) FROM ".$group; 

  What I want to do is this but MySQL doesn't like it:

"SELECT date FROM ".$group." WHERE Uploaded = Max(Uploaded)";

and I would need to use this same concept to get all the other fields in separate variables too.

My fields are (Field_name, Data_type);:

(Uploaded, timestamp);(Date, Text); (Time, Text); (Location, Text); (DocLoc, Text); (Docloc will be the location of the Agenda's syllabus).

Do Date, Time, Location and DocLoc really need to be 65000 chars long?

 

Why multiple tables for board/commitee/commission and not a single table storing board/commitee/commission in each row?

 

Anyway,

SELECT Date, Time, Location, DocLoc FROM tablename 
WHERE uploaded = (SELECT MAX(uploaded) FROM tablename)

Thank you very much, that really simplifies what I ended up doing which used two functions that now seem unnecessary. I will change the fields to something more appropriate. Lastly I do think each table is a good thing because if you have an additional field with the for the name of the board committee or commission that means alot more data which does not need to be stored over and over again. thanks so much for the other tips. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.