Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2011
    Posts
    3

    Red face Unanswered: union all order by id

    hi im new here i hope you help me
    ihave this code but returns error, can you help me i appreciate it
    Code:
    $result = mysql_query("SELECT *
    FROM (
        select column1, column2 from tbl1
        union all 
        select column1, column2 from tbl2
    )
    order by DESC id LIMIT 4");
    while($row = mysql_fetch_array($result))
    {}
    Last edited by aramkamil; 04-25-11 at 17:26. Reason: Wrong typing

  2. #2
    Join Date
    Apr 2011
    Posts
    3

    please help

    please help

  3. #3
    Join Date
    Apr 2011
    Posts
    3

    Fxed

    Thanks guys i have fixed the problem and here is how:
    Code:
    $result = mysql_query('(SELECT colum1, colum2 FROM tbl1 ORDER BY date DESC LIMIT 2) UNION ALL
    (SELECT colum1, colum2 FROM tbl2 ORDER BY date DESC LIMIT 1) UNION ALL
    (SELECT colum1, colum2 FROM tbl3 ORDER BY date DESC LIMIT 1)');
    while($row = mysql_fetch_array($result)){}
    thanks
    it made me so tired it maked me busy about 5 hours

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •