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 6152955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:00:39+00:00 2026-05-23T20:00:39+00:00

This is the problem – how do I make the following work WITHOUT using

  • 0

This is the problem – how do I make the following work WITHOUT using UNION or a second select query?

Code:

$query = "SELECT DISTINCT(t.tid), IF(last_job2 <= 2000, last_job2, last_job) AS last_job
                      FROM smf_posts p
                        LEFT JOIN smf_topics t ON (p.topic_id=t.tid)"

So that when I add in the WHERE statements it can recognize the if / as of last_job?

For instance in the WHERE below

WHERE last_job < 2000

In other words, I want this “IF(last_job2 <= 2000, last_job2, last_job) AS last_job”
to be recognized by the time it reaches “WHERE last_job < 2000”. With my current code it does not follow “IF(last_job2 <= 2000, last_job2, last_job) AS last_job”.

Thanks!

  • 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-23T20:00:40+00:00Added an answer on May 23, 2026 at 8:00 pm

    Just a wild guess. Do you want this?:

    SELECT DISTINCT(t.tid)
         , IF(last_job2 <= 2000, last_job2, last_job) AS last_job
    FROM smf_posts p
      LEFT JOIN smf_topics t ON (p.topic_id=t.tid)
    WHERE IF(last_job2 <= 2000, last_job2, last_job) < 2000
    

    or perhaps this:

    SELECT DISTINCT(t.tid)
         , IF(last_job2 <= 2000, last_job2, last_job) AS last_job
    FROM smf_posts p
      LEFT JOIN smf_topics t
        ON (p.topic_id=t.tid)
        AND IF(last_job2 <= 2000, last_job2, last_job) < 2000
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This problem is driving me crazy. I have the following code: 'unprotect sheet If.Range(Start).Row+1<.Range(End).Row
This problem crops up every now and then at work. Our build machine can
This problem pertains to Java By using RandomAccessFile I intend to be able to
this problem is killing me, here is my code import java.text.ParseException; import java.text.SimpleDateFormat; import
this problem is part of a bigger page but I've simplified the code to
This problem only occurs using IE (only tested in IE 7, works fine in
This problem is creeping up in many places in my code,but the general behavior
This problem is very weird to me. I am using jQuery to submit some
I am having this problem.. using (var transaction = Session.BeginTransaction()) { var t =
this problem is going to make me bald. Save my hair plz. i have

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.