Jump to content

Need An Sql Statement For This...


Piyush

Recommended Posts

My table consist of following columns...id(auto_increment),scrapto(int),scrapfrom(int),time(date/time),date(date/time),message(text)where scrapto and scrapfrom consists of member's id.i want to pick up latest scraps of any member..how can i do this...i thought i will first pick up all scraps of specific member ordered by date...but the problem is i also want to order them by time..how can i do both things ...is there any function in php through which i can sort the result which came out of an query... thanks...

Link to comment
Share on other sites

Rather than having 2 seperate date and time fields, you would be better to use a single datetime field that conatins both.The function NOW() in mysql insert the actual date/time, but you can even save every date/time by entering manually.The data is stored in the format: YYYY-DD-MM HH:MM:SSYou could then use mysql to order your selction with something simple like ORDER BY scraptimedate desc, or various other options. The key is to having the correct field in the first place to simplify the rest ot the coding.

Link to comment
Share on other sites

Rather than having 2 seperate date and time fields, you would be better to use a single datetime field that conatins both.The function NOW() in mysql insert the actual date/time, but you can even save every date/time by entering manually.The data is stored in the format: YYYY-DD-MM HH:MM:SSYou could then use mysql to order your selction with something simple like ORDER BY scraptimedate desc, or various other options. The key is to having the correct field in the first place to simplify the rest ot the coding.
thanks for reply
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...