You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .

sbj: two tables, one query, getting the latest for each in tbl1 from tbl2
hi,
Could you please help me with this?
Say I have two tables

tbl1 {
id int auto_increment,
name string,
description string
}

tbl2 {
id int,
file_url int,
version int
}

These two tables are used for software project releases on a web site,
`tbl1` keeps the project `name`, `description`, and auto inc. `id` and the `tbl2` keeps files released for a project, `id` references `tbl1.id`, the file_url is the file name that would be presented for a given `version`. So as you might guessed a project once is inserted into tbl1 then each time a file is released for a given project its name along with its version is inserted into the tbl2 referencing tbl1.id, so in the end e.g. Project1 Project2 Project3 each has ~20 files versions start with 0 up to say 20, my question is; executing only __one__ query, how do I get the latest (highest version) file name for a given project _and_ optinaly for all projects, _again_ only one query. Feel free to alter the tables, in a sense all I need to know is how/is it possible/ what needs to be used.