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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:20:26+00:00 2026-05-11T17:20:26+00:00

I’m having trouble writing a query. I have a support tabled called ‘MYTABLE’ and

  • 0

I’m having trouble writing a query. I have a support tabled called ‘MYTABLE’ and it has a column called ‘TABLENAME’ that can have one or many table names in it. Multiple Tables are separated with commas.

Example:

TBLUSER
TBLUSER, TBLACCOUNT

I’m trying to write an query that will identify any entries in the MYTABLE table that are not valid tables in the database. I was able to write the follow….

                     SELECT *
                       FROM MYTABLE T1
            LEFT outer JOIN ALL_TAB_COLS T2
                         ON (    upper(T1.TABLENAME) = upper(t2.Table_Name) 
                             AND T2.Owner = 'ME'
                             )
                       WHERE TABLE_NAME IS NULL;

And it works exactly how I want – but it only works when the entry in MYTABLE contains a single table. When there are multiple tables separated by commas – it fails. My SQL skills are somewhat lacking and my natural instinct is to ‘Do a For Each’ but I feel that’s not the right approach (and I have no idea how to do that in SQL).

  • 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-11T17:20:26+00:00Added an answer on May 11, 2026 at 5:20 pm

    You’re storing a string in MYTABLE.TABLENAME and trying to match it against a string in ALL_TAB_COLS.TABLE_NAME (which btw, I don’t see any reason you would use ALL_TAB_COLS instead of ALL_TABLES in this case).

    If your string is ‘TBLUSER, TBLACCOUNT’, it’s not going to be equal to the string ‘TBLUSER’ or the string ‘TBLACCOUNT’. That’s all the expression upper(T1.TABLENAME) = upper(t2.Table_Name) is testing — are these two string equal? You seem to be expecting that it somehow “knows” that your data happens to be a comma-separated list of table names.

    The brute-force method to make what you have work using string comparisons is to change the condition to ','||upper(T1.TABLENAME)||',' LIKE '%,'||upper(t2.Table_Name)||',%. So you basically would be looking at whether TABLE_NAME is a substring of your TABLENAME column value.

    However, the real point is that this is a not very good database design. First of all, from a simple point of clarity, why would you name a column “TABLENAME” (singular) and then put values in it that represent multiple table names? If you’re going to do that, you should at least call it something like “TABLENAMELIST”.

    More importantly, this is not generally the way we do things in relational databases. If your MYTABLE looks like this:

    ID       TABLENAME
    1        TBLUSER
    2        TBLUSER, TBLACCOUNT
    

    then a more proper relational way to design the table would be:

    ID       TBL_NUM    TABLENAME
    1        1          TBLUSER
    2        1          TBLUSER
    2        2          TBLACCOUNT
    

    Then your query would work as-is, more or less, because the TABLENAME column would always contain the name of a single table.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
We're building an app, our first using Rails 3, and we're having to build
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.