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

  • Home
  • SEARCH
  • 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 9182305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:31:43+00:00 2026-06-17T18:31:43+00:00

I have such code: (on RoR): @types = Type.where(TYP_MOD_ID = ? AND (SUBSTRING(TYP_PCON_START,1,4) <=

  • 0

I have such code:
(on RoR):

@types = Type.where("TYP_MOD_ID = ? AND (SUBSTRING(TYP_PCON_START,1,4) <= ?) AND (SUBSTRING(TYP_PCON_END,1,4) >= ?) AND TYP_KV_FUEL_DES_ID = ? ", params[:models], params[:year], params[:year], params[:fueltype]).order("TYP_HP_FROM")

But sometimes TYP_PCON_END is null in db…. How in such case use not null, but my value, sended by ruby (date.now(YEAR))?

So how if field is null use another value?
How to check on null, and use my code if not null (SUBSTRING(TYP_PCON_END,1,4) >= ?)
and another:

? >= ?

if null?

  • 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-17T18:31:45+00:00Added an answer on June 17, 2026 at 6:31 pm

    You can use COALESCE:

    SUBSTRING(COALESCE(TYP_PCON_END, 'some default string'),1,4) > ?
    

    If you don’t need the substring for your default value, then you would just do it this way:

    COALESCE(SUBSTRING(TYP_PCON_END,1,4), 'AAAA') > ?
    

    This works since doing a SUBSTRING on a null value will yield null as well.

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

Sidebar

Related Questions

I have such code: = hidden_field(:user_id, nil, :value => params[:user_id]) But it is generating
I have such code: def accum_search if params[:akbcap].present? akbcap_array = [12,18,19,20,25,30,35,36,38,40,41,42,44,45,46,47,50,52,53,54,55,56,58,60,61,62,63,64,65,66,68,69,70,71,72,74,75,77,80,85,88,90,91,92,95,98,100,102,110,115,120,125,130,135,140,170,180,185,190,192,200,210,220,225] min, max =
I have such code: <div style=width:500; height:500;> <input type=button/> </div> how to fit the
I have such code: Log.d(TAG, day=%d, month=%d, year=%s, day, month, year); Calendar c =
I have such code: <script src=http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js type=text/javascript></script> <script type=text/javascript> $(document).ready(function(){ var my_id = 'iddate';
I have such javascript code alert(DATE.value); var d = new Date(DATE.value); var year =
I have such an Adsense code: <script type=text/javascript><!-- google_ad_client = ca-pub-12345; /* my advertisement
I have such code: <script type=text/javascript> function changeFontSize(element,step) { step = parseInt(step,10); var el
i have such code (copy paste from wiki). Its multiplication of those big numbers
I have such code: $updateSQL = UPDATE `Rooms` R SET R.Revenue = {$s['Revenue']}, R.Ave_rent

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.