RAH Posted August 20, 2007 Share Posted August 20, 2007 Hi, I have the following SQL query: SELECT * FROM file_items ORDER BY view DESC LIMIT 0, 1 This lists the top viewed file in the database. However there's a problem with this. I need to ensure that file is of a certain type. In a seperate table named "files" there is a column named "type". The above query needs to be modified so that these two tables are cross-referenced. Both tables have a column named "id" which could be used to match things up. I'm not quite sure how to go about this - all help would be greatly appreciated. Thanks. Link to comment https://forums.phpfreaks.com/topic/65749-solved-sql-query/ Share on other sites More sharing options...
js_280 Posted August 20, 2007 Share Posted August 20, 2007 SELECT * FROM file_items LEFT JOIN files ON file_items.id = files.id WHERE files.type = "needed type here" ORDER BY file_items.view DESC LIMIT 0, 1 Link to comment https://forums.phpfreaks.com/topic/65749-solved-sql-query/#findComment-328508 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.