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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:17:18+00:00 2026-06-10T14:17:18+00:00

SELECT IFNULL(Col,’b’) FROM Table Checks Col and returns Col if is not null if

  • 0
SELECT IFNULL(Col,'b') FROM Table

Checks Col and returns Col if is not null if not it returns b.

How do I check Col, and return ‘a’ if not null or ‘b’ if null.

I tried this:

SELECT IF(Col=NULL,'a','b') FROM Table

Which always returns ‘b’. How is this done?

  • 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-06-10T14:17:20+00:00Added an answer on June 10, 2026 at 2:17 pm

    Use IS NULL to check whether a column is null, instead of = NULL.

    Every value compares with NULL the result will be NULL, so you will always get b.

    SELECT IF(Col IS NULL,'a','b') FROM Table
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This - gives incorrect values for total_classes SELECT IFNULL(count(wc.id_wc),0) AS total_classes FROM `all_tag_relations` AS
I have this: SELECT CONCAT(forename,' ',IFNULL(initials, ''),' ',surname) AS name FROM users How do
I have a query which contains a subquery which is something like this IFNULL((SELECT
When i run this query: select (IFNULL(ROUND(convertUnits('40892',SUM(o.qty),o.pricingUnit,'FT')),0)) as oItemQty, (SELECT IFNULL(sum(i.qty),0) from inventory i
SELECT S.CLIENT,S.IP_DOMAIN as IP, IFNULL(K.DATE, DATE '0000-00-00') AS RecentDate FROM PLD_SERVERS AS S JOIN
I have this query: SELECT COUNT(*) AS invoice_count, IFNULL(SUM(qa_invoices.invoice_total), 0) AS invoice_total, IFNULL(SUM(qa_invoices.invoice_discount) ,0)
SELECT REPLACE([strUrl], '/myoldurl', '/mynewurl') FROM [UrlRewrite] If strUrl is /myoldurl/myoldurl_something_else , it returns /mynewurl/mynewurl_something_else
select tf.Id,tf.Name,tf.LName,tf.Rank,tf.Category where tf.Id not in (select fighter_id from tbl_player_fighter where league_id=91) and tf.Status
I have a query that returns all stream posts from users (with comments): SELECT
select value1 as value from T1 where id=10; if id does not exist in

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.