Question:
Help with SQL query statement?
yeoys2003
2009-04-16 09:01:26 UTC
This is my database.

no = auto increment number
id = id number of image
cat = image category

no, id, cat
1, 1, dance
2, 2, dance
3, 1, sing
4, 2, sing
5, 3, sing
6, 3, dance
7, 4, dance
8, 1, cook
9, 2, cook

So how do i generate the sql so i juz show all categories (order by latest updated) with the latest uploaded image.

Example
Cook2.jpg //newest image of the newest category
Dance4.jpg // newest image of 2nd newest category
Sing3.jpg // newest image of 3rd newest category

i have tried many times and failed many times. what is the SQL statement so i can generate that?
Three answers:
2009-04-16 11:49:00 UTC
I do not see a field for "date" so your database is not set up right but here is a sample query

assuming you are using PHP and mysql if MS Access then it is a little different but the query pattern is the same



$query = mysql_query("SELECT cat FROM table_name ORDER BY date ASC");

while($cats = mysql_fetch_assoc($query)){

extract($cats);

echo $cat . "
";

}
?
2016-12-08 23:42:26 UTC
you may desire to save the folder places interior the database, the sq. might look something like choose * FROM REQ while Foldername = 'foldername1' as quickly as you had the end result for this option you may desire to pass to the folder to get the tips you require. sq. is a database language, no longer a filesystem language, so any documents extracted from the database might could want for use to show you contained in the direction of the folder you desire,
Serge M
2009-04-16 12:02:32 UTC
Select cat,

cat+cast(max(id) as varchar)+'.jpg'

From YourTable

Group by cat


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...