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

The Archive Base Latest Questions

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

I have the following tables : Table1 ( Col1 : varchar2, Col2 : number,

  • 0

I have the following tables :

Table1 ( Col1 : varchar2, Col2 : number, Col3 : number)
Table2 ( Col1 : number, Col2 : varchar2, Col3 : varchar2)

I want to run a query like this :

select distinct Col2 from Table1 where Col1 in 
(
   select Col1 from Table2
)

Table1.Col1 is of type varchar2 while Table2.Col1 is of type number. so, I need to do some casting, it seems but it fails to succeed.

The problem is that any attempts to run the query returns the following error :

  ORA-01722: invalid number
  01722. 00000 -  "invalid number"
  *Cause:    
  *Action:

Table1.Col1 contains some null values.

  • 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-26T21:56:11+00:00Added an answer on May 26, 2026 at 9:56 pm

    Something like

    SELECT distinct col2
      FROM table1
     WHERE col1 IN (SELECT to_char(col1)
                      FROM table2)
    

    should work. Depending on the relative size of the two tables, it may be more efficient to do an EXISTS instead

    SELECT distinct col2
      FROM table1 t1
     WHERE EXISTS( SELECT 1
                     FROM table2 t2
                    WHERE to_char(t2.col1) = t1.col1 );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have the following query SELECT table1.col1, table2.col2 FROM table1 INNER JOIN table2
I have a query like queryStr := 'SELECT col1, col2, col3, col4 FROM Table1
I have the following query: select col1, sum( col2 ), count( col3 ) from
I have an update query like following: update table TABLE1 set COL1 = 'X'
In the following query SELECT col1,col2 FROM table1 WHERE col3='value1' AND col4='value2' If I
I have a table with the following Table1 col1 col2 ------------ 1 A 2
Assume I have the following style table, col1 col2 and col3 have same value
I have the following table Id col1 col2 col3 1 c 2 m 2
I have the following query SELECT Count(*) as Total_Count, Col1 FROM Table1 GROUP BY
I have a table as below: table1 col1 col2 col3 1 A 1 2

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.