简体   繁体   中英

Select from multiple images uploaded to database

I want to select from multiple images uploaded to database and target folder, so i want to select the first image uploaded to display on my homepage:

$fetch1 =mysqli_query($con,"SELECT * FROM propertydescription,propertygallery
WHERE propertydescription.propertyID=propertygallery.propertyID ORDER BY Date DESC LIMIT 10 "); 

The table consist of 3 columns Userid,PropertyID,Image_Name. The userid is from session while the propertyID is from the current page.

Based on the minimal information provided, the query you are looking for would be something like:

SELECT 
    pg.* # Get the property gallery columns 
FROM propertydescription pd
INNER JOIN propertygallery pg ON pd.propertyID = pg.propertyID
WHERE pd.propertyID = 123
ORDER BY pg.created_at DESC # Not sure what you call this column 
LIMIT 1

This will get the most recent row of propertygallery as long as it has a property description record where the propertyID matches the provided value -- in this case, I just put 123 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM