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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:01:32+00:00 2026-05-26T13:01:32+00:00

I have to execute a SQL made from some users and show its results.

  • 0

I have to execute a SQL made from some users and show its results. An example SQL could be this:

SELECT t1.*, t2.* FROM table1 t1, table2 t2, where table1.id = table2.id

This SQL works fine as it is, but I need to manually add pagination and show the rownum, so the SQL ends up like this.

SELECT z.* 
FROM(       
    SELECT y.*, ROWNUM rn
    FROM (                   
        SELECT t1.*, t2.* FROM table1 t1, table2 t2, where table1.id = table2.id
    ) y      
    WHERE ROWNUM <= 50) z         
WHERE rn > 0

This throws an exception: “ORA-00918: column ambiguously defined” because both Table1 and Table2 contains a field with the same name (“id”).

What could be the best way to avoid this?

Regards.

  • UPDATE

In the end, we had to go for the ugly way and parse each SQL coming before executing them. Basically, we resolved asterisks to discover what fields we needed to add, and alias every field with an unique id. This introduced a performance penalty but our client understood it was the only option given the requirements.

I will mark Lex answer as it´s the solution we ended up working on.

  • 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-26T13:01:33+00:00Added an answer on May 26, 2026 at 1:01 pm

    I think you have to specify aliasses for (at least one of) table1.id and table2.id. And possibly for any other corresponding columnnames as well.

    So instead of SELECT t1.*, t2.* FROM table1 t1, table2 use something like:

    SELECT t1.id t1id, t2.id t2id [rest of columns] FROM table1 t1, table2 t2
    

    I’m not familiar with Oracle syntax, but I think you’ll get the idea.

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

Sidebar

Related Questions

When you execute a SQL query, you have to clean your strings or users
I have a select from (nothing to complex) Select * from VIEW This view
I have this query: select top(2) property_id_ref ,image_file ,property_name from property_master a inner join
I have an Execute SQL task (SQL 2008) where I'm using two SSIS variables
Hello I have a very large SQL script and while trying to execute it
I'm working on a legacy product and i have some SQL being executed through
I have a stored procedure that executes much faster from Sql Server Management Studio
I have an HTML textbox that contains some SQL code that I need executed.
I have a SQL Script that I execute in a job to transform tables
I'm working with some SQL 2005 CLR code written in C#. We have recently

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.