Professional Web Applications Themes

sql problem with limit cross two tables - MySQL

I want to get the top 5 popular site from the following table( access and site table) how can i define the sql using "limit" so that those site with rank 0 will be excluded from top 5 site select * from access, site where rank <> 0 orderby access.hit limit 0,5 something like this? I can not get the result i am looking for. access table company_id | hit 1. 1000 2. 950 3. 5000 4. 4562 5. 5478 6. 456 7. 7894 8. 47891 9. 784412 10 4544 site table id name rank 1. 5 2. google.com 0 ...

  1. #1

    Default sql problem with limit cross two tables

    I want to get the top 5 popular site from the following table(
    access and site table)

    how can i define the sql using "limit" so that those site with rank 0
    will be excluded from top 5 site
    select * from access, site where rank <> 0 orderby access.hit limit 0,5
    something like this? I can not get the result i am looking for.

    access table
    company_id | hit
    1. 1000
    2. 950
    3. 5000
    4. 4562
    5. 5478
    6. 456
    7. 7894
    8. 47891
    9. 784412
    10 4544

    site table
    id name rank
    1. 5
    2. google.com 0
    3. news.com 0
    4. tsn.com 7
    5. nytimes.com 4
    6. sony.com 1
    7. GM.com 4
    8. Microsoft.com 2
    9. Sun.com 0
    10 MSN.com 1


    M Guest

  2. #2

    Default Re: sql problem with limit cross two tables

    "M D" <com> wrote in message news:s61Vg.1888$.. 

    Assuming access.company_id and site.id relate:

    SELECT *
    FROM site
    INNER JOIN access ON access.company_id = site.id
    WHERE rank > 0
    ORDER BY access.hit DESC
    LIMIT 0,5



    Bosconian Guest

Similar Threads

  1. Symptom mimics cross domain problem
    By Chip Thomas in forum Macromedia Flex General Discussion
    Replies: 8
    Last Post: May 12th, 08:28 PM
  2. Class Problem(cross)
    By Savas Ates in forum ASP.NET Web Services
    Replies: 1
    Last Post: December 10th, 02:29 AM
  3. Cross platform problem!!!
    By Gordon Robinson in forum Macromedia Director Basics
    Replies: 2
    Last Post: April 28th, 08:06 AM
  4. Cross-platform --- Win/Mac OS X/Classic OS... Major Problem!!!
    By Nitin Mistry in forum Macromedia Director Lingo
    Replies: 1
    Last Post: October 9th, 12:12 PM
  5. cross-corr time/array lag problem
    By Qubert in forum Ruby
    Replies: 6
    Last Post: July 12th, 06:04 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139