SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Put LIMIT and ORDER in sql join?

    I want put LIMIT and ORDER, in following query. how is it?

    PHP Code:
    ORDER BY tour_foreign.id asc
    LIMIT $offset
    $coun_page 
    In the this query:

    PHP Code:
    SELECT
                   
    @rownum := @rownum 1 rownum,
                   
    tour_foreign.id
                   
    tour_foreign.name,
                   
    tour_foreign.airline,
                   
    MIN(tour_foreign_residence.name_re) AS name_re
                   
    tour_foreign.service
                   
    tour_foreign.date_go
                   
    tour_foreign.date_back
                   
    tour_foreign.term,
                   
    tour_foreign.useradmin_submit,
                   
    tour_foreign.date_submit,
                   
    GROUP_CONCATtour_foreign_residence.name_re 
                         ORDER BY tour_foreign_residence
    .name_re 
                         SEPARATOR 
    '، '
                       
    ) AS name_re_all
                FROM   tour_foreign 
                  INNER JOIN tour_foreign_residence 
                ON 
    tour_foreign.id tour_foreign_residence.relation )
                  
    JOIN (SELECT @rownum := 0r
                GROUP BY  tour_foreign
    .id            
                HAVING name LIKE 
    '%" . $find . "%'
                
    OR     airline LIKE '%" . $find . "%'
                
    OR     name_re_all LIKE '%" . $find . "%'
                
    OR     service LIKE '%" . $find . "%'
                
    OR     date_go LIKE '%" . $find . "%'
                
    OR     date_back LIKE '%" . $find . "%'
                
    OR     term LIKE '%" . $find . "%'
                
    OR     useradmin_submit LIKE '%" . $find . "%'
                
    OR     date_submit LIKE '%" . $find . "%' 

  2. #2
    SitePoint Enthusiast Sam32's Avatar
    Join Date
    Sep 2010
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Put it at the end of the query.

  3. #3
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, i have a other problem with rownum, i have in database tour_foreign three row and should rownum is this: 1, 2, 3 but it is: 12, 13, 14. Did you know how should fix it?


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
  •