Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4563458
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:21:41+00:00 2026-05-21T18:21:41+00:00

So what I want to to is put users that don’t have a profile

  • 0

So what I want to to is put users that don’t have a profile picture at the VERY VERY bottom of the page.

but if they do have a picture, then it skips them, and adds them to the following rules

SELECT users.id as id, users.username as username,    
       DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW())-TO_DAYS(userprofiles.birthdate)), '%Y')+0 AS age,   
       userprofiles.defaultpictureid as picture, city.City 
  FROM users, 
       userprofiles, 
       Cities as city 
 WHERE users.id = userprofiles.userid 
   AND city.CityId = userprofiles.city 
   AND userprofiles.online = '1' 
   AND userprofiles.country = ".$this->country." 
   AND userprofiles.state = ".$this->state." 
ORDER BY if (userprofiles.city = ".$this->city.",0,1) AND userprofiles.membertype DESC
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T18:21:41+00:00Added an answer on May 21, 2026 at 6:21 pm

    Maybe I’m misreading the question since you already have the concept of an IF inside the order by but this should work assuming when defaultpictureid is null when the user doesn’t have a picture

    ....
    ORDER BY
        if( userprofiles.defaultpictureid is null,1,0),
        if (userprofiles.city = ".$this->city.",0,1)  
    ....
    

    Some DBs don’t have an IF statement like this. In ones that don’t they usually have the case (mysql has both)

    ORDER BY
        CASE WHEN userprofiles.defaultpictureid is null THEN 1 ELSE 0 END,
    

    this is also useful when you have more values than just 1 and 0 and you don’t want to do nested ifs

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website where I want users that sign up to get their
I want to put validator so that if the user does not put the
For IE7 users, I want to put in some specific Please upgrade now banner.
I want to allow users to put in am img url instead of uploading
These fine folks are my users: http://www.youtube.com/watch?v=o4MwTvtyrUQ If you don't want to enjoy the
I have to write an architecture case study but there are some things that
I have an array called $users (below), that i would like to print first_name
I am writing a webservice that allows users to post files and then retrieve
I have a little statistics block that I want to be available in several
I'm trying to do a fairly basic HTTP PUT using RestKit. I don't want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.