Get the most recent records comparing them on multiple tables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deiv82
    New Member
    • Jul 2010
    • 10

    #1

    Get the most recent records comparing them on multiple tables

    Hi, I'm trying to get in my homepage the last 10 product-schedules inserted in my website. These I should get from different tables in my database, that have all the same fields but every table has a different kind of product.

    So, I should virtually join all the tables and then get of these the 10 tables with the most recent date.
    The problem is that I'm able to do this, but just on one table:
    Code:
    require("db/db.php");
    $lastinserted=mysql_query("SELECT img,link,numclick,description,order FROM $table1 ORDER BY date DESC, order LIMIT 0,1",$link);
    while ($row=mysql_fetch_array($lastinserted,MYSQL_NUM)) {
    printf("<div class='grid_8'><div class='screen'>%s</div><div class='text'><h2>%s<span class='visite'> &nbsp;- %s visite</span></h2> %s</div></div>", $row[0], $row[1], $row[2], $row[3]);
    }
    mysql_free_result($lastinserted);
    mysql_close($link);
    I guess I should use the 'join' command but I have no idea how…
    some advice?
    thanks a lot
  • deiv82
    New Member
    • Jul 2010
    • 10

    #2
    ok i've resolved the problem using UNION ALL!

    thanks however

    byebye

    Comment

    Working...