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).

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.