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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:47:49+00:00 2026-06-16T09:47:49+00:00

assume my table contains following columns Roll_number numeric not null Subject1 varchar(40) null Subject2

  • 0

assume my table contains following columns

 Roll_number numeric           not null
 Subject1    varchar(40)       null
 Subject2    varchar(40)       null
 . . .
 Subject8    varchar(40)       null

i have to search a subject in all these subject1 to 8 using SQL Query. what would be the best query to search a substring in all these columns keeping in mind that any one of these can have NULL value.

i wrote

select * 
from students_data 
where subject1="BIOLOGY" or subject2="BIOLOGY" . . . . or subject8="BIOLOGY" 

but i need a simple query because in actual i have more than 20 columns in my table

The query

select * from table1 where "BIOLOGY" in (subject1,subject2,subject3)

was helpful but what if i have to match just the substring (part of that subject) like
“BIO” in that table fields

  • 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-16T09:47:51+00:00Added an answer on June 16, 2026 at 9:47 am

    How about this?

    SELECT * 
    FROM students_data
    WHERE subject1 + ' ' + subject2 + ' ' + ..... + subject8 LIKE '%BIOLOGY%';
    

    Update 1

    For NULL values, use below.

    SELECT * 
    FROM students_data
    WHERE ISNULL(subject1,'') + ' ' + ISNULL(subject2,'')
    + ' ' + ..... + ISNULL(subject8,'') LIKE '%BIOLOGY%';
    

    For using BIO, you can use LIKE '%BIO%';

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

Sidebar

Related Questions

Assume I have a table called table and I have 3 columns, a, b,
Assume I have the following style table, col1 col2 and col3 have same value
I have a city table that has two columns from_city to_city now lets assume
I have following query select * from table1 if table1 contains text type column/columns
Lets assume that I have Table which contains Username and the other one which
Assume my table column contains the following 2 string rows: 1, 5, 2, 31,
I have a database with a single table right now, which contains the following
I have a table with around 19 columns which contains reasonable large amount of
Assume I have a table like this: column A(int) column B(int) 1 2 2
Assume I have two tables: Table MY_ENTITY ID: PK OTHER_ID: FK to table OTHER

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.