Jump to content

[SOLVED] please how can you do this?


jonniejoejonson

Recommended Posts

I have 2 tables:

 

images_table

imageId : imageFilename : dateCreated

 

videos_table

videoId : videoFilename : dateCreated

 

I want to select the id's of the 10 most recent videos or images.

Therefore i need to somehow join the 2 tables and order them by dateCreated ASC and LIMIT 0,10.

 

any ideas thanks Jon.

Link to comment
Share on other sites

Hi

 

That is pretty much what I was about to put, just with a field to say whether it was an image or video.

 

SELECT *
FROM 
(SELECT 'Image' AS Type, imageId AS Id, imageFileName AS FileName, dateCreated FROM images_table
UNION
SELECT 'Video' AS Type, videoId AS Id, videoFilename AS FileName, dateCreated FROM videos_table) Deriv1
ORDER BY dateCreated DESC
LIMIT 0,10

 

All the best

 

Keith

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.