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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:15:04+00:00 2026-06-17T12:15:04+00:00

I have a Students table, which contains 7 address fields. I need to display

  • 0

I have a Students table, which contains 7 address fields.

I need to display 1 row each for student where the address fields have carriage return, if any.

It’s confused after this.

The 9th column (1st column – Student ID, 2-8 column – 7 address fields) must contain the list of column names which have a carriage return ( like addr_1, addr_3, 1 for each student ID separated by a comma)

The 10th column must contain the illegal character (in this case, carriage return).

This code must be further extended to other illegal characters identified now and then and a report has to be generated.

I am unable to work on 9th and 10th columns. Can anyone help?

SELECT pty.id,
a.addr_1,
a.addr_2,
a.addr_3,
a.addr_4,
a.addr_5,
a.addr_6,
a.addr_7
FROM addr a 
inner join contact cON a.idf = c.add_idf
inner join pty ON c.pty_id = pty.id
WHERE 
INSTR(a.addr_1,CHR(13)) > 0 OR
INSTR(a.addr_2,CHR(13)) > 0 OR
INSTR(a.addr_3,CHR(13)) > 0 OR
INSTR(a.addr_4,CHR(13)) > 0 OR
INSTR(a.addr_5,CHR(13)) > 0 OR
INSTR(a.addr_6,CHR(13)) > 0 OR
INSTR(a.addr_7,CHR(13)) > 0;
  • 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-17T12:15:05+00:00Added an answer on June 17, 2026 at 12:15 pm

    This sounds like a homework question. So, let me give you some hints:

    (1) You can generate a table using syntax, such as:

    select chr(13) as badchar from dual union all
    select '!' . . .
    

    (2) You can cross join this into the table and use a very similar where clause.

    (3) You can then select the bad character from the table.

    (4) You’ll need an aggregation.

    Actually, I would be inclined to drop the requirement of one row per student and instead have one row per student/bad character. Here is an approach:

    select a.id,
           a.addr_1, a.addr_2, a.addr_3, a.addr_4, a.addr_5, a.addr_6, a.addr_7,
           ((case when INSTR(a.addr_1, b.badChar) > 0 then 'addr_1,' else '' end) ||
            (case when INSTR(a.addr_2, b.badChar) > 0 then 'addr_2,' else '' end) ||
            (case when INSTR(a.addr_3, b.badChar) > 0 then 'addr_3,' else '' end) ||
            (case when INSTR(a.addr_4, b.badChar) > 0 then 'addr_4,' else '' end) ||
            (case when INSTR(a.addr_5, b.badChar) > 0 then 'addr_5,' else '' end) ||
            (case when INSTR(a.addr_6, b.badChar) > 0 then 'addr_6,' else '' end) ||
            (case when INSTR(a.addr_7, b.badChar) > 0 then 'addr_7,' else '' end)
           ) as addrs,
           b.badChar
    from a cross join
         (select chr(13) as badChar from dual) as b
    WHERE INSTR(a.addr_1, b.badChar) > 0 OR
          INSTR(a.addr_2, b.badChar) > 0 OR
          INSTR(a.addr_3, b.badChar) > 0 OR
          INSTR(a.addr_4, b.badChar) > 0 OR
          INSTR(a.addr_5, b.badChar) > 0 OR
          INSTR(a.addr_6, b.badChar) > 0 OR
          INSTR(a.addr_7, b.badChar) > 0;
    

    It leaves an extra comma at the end of the column names. This can be removed by making this a subquery and doing string manipulations at the next level.

    To put all badchars on one line would require an aggregation. However, I am not clear what the 9th and 10th columns would contain in that case.

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

Sidebar

Related Questions

I have a table which contains student grades (SAG). I need to show all
I have a STUDENT table which contains data about students from a faculty: STUDENT(ID,
i have a table Students which contains the following colums: Id,FirstName,LastName,Adress . The colum
I have a table row which contains a button: <form id='studentAddForm'> <table id='removetbl'> <tr>
I'm trying to display all such rows of a table STUDENTS which have a
In MySQL, I have a Student Table which contains a StudnetId column which goes
i have a table named students which have student details id,mark,name i want to
I have an attendance table which contains student's attendance date and attendance status. Is
I have a database Student which contains about 20 tables. one of the tables
i have a table which consists of student details like roll no, Name, age.

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.