SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ordering by multiple columns

    Hi Guys!

    Is it okay to order by the featured column as well as date_posted as I have done below?

    Code:
    SELECT jobs.job_title, companies.company_name, companies.company_url, companies.logo_thumbnail, jobs.job_url, jobs.job_salary, jobs.job_ote, jobs.job_perks, jobs.job_description, jobs.location, jobs.date_posted, industries.industry, job_types.job_type, count( applications.id ) AS applications, count( featured_jobs.id ) AS featured
    FROM jobs
    INNER JOIN companies ON companies.id = jobs.company_id
    INNER JOIN industries ON industries.id = jobs.industry
    INNER JOIN job_types ON job_types.id = jobs.job_type
    LEFT OUTER JOIN applications ON applications.job_id = jobs.id
    LEFT OUTER JOIN featured_jobs ON featured_jobs.job_id = jobs.id
    WHERE jobs.status = 'on'
    GROUP BY jobs.id
    ORDER BY featured DESC , date_posted DESC
    LIMIT 0 , 30

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,501
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Did you try it?
    Does it give an error?
    Does it return the results you need?

    "okay" is very vague

  3. #3
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It does actually give the correct results just wanted to check that I am using the correct syntax.

    Thanks.


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
  •