Note that there are some explanatory texts on larger screens.

plurals
  1. POselecting multiple times from two tables to get two different result
    text
    copied!<p>I am using apex application building to create a report. </p> <p>Table</p> <p><strong>staff</strong></p> <pre><code>id name 201 john 302 sarah 787 bob </code></pre> <p><strong>product</strong></p> <pre><code>product_editor_id product_name 201 car 307 shoe 728 airbag </code></pre> <p>as you can see in the staff table I have staff details and in the product I have the staff id to show the staff that created it.</p> <p>in my report I have selected everything from the staff table, but you see where I have staff <code>id</code> i don't want to show the <code>id</code> but instead their name</p> <p>I have rewritten a query for this. The reason why I am asking this question is that in the previous query I had something like this</p> <pre><code>select * from staff Inner join company_car ON staff.staff_car_id=company_car.vehicle_id_staffid </code></pre> <p>if that query doesn't make sense. Basically I did this to only display staff that has a company car and the vehicle_id_staffid is the same as the staff id.</p> <p>anyways on top for that query I need to add my new query to it which is </p> <pre><code>select distinct name from staff left join product on staff.id=product.product_editor_id </code></pre> <p><strong>I tried</strong></p> <pre><code>select * from staff Inner join company_car ON staff.staff_car_id=company_car.vehicle_id_staffid UNION select distinct name from staff left join product on staff.id=product.product_editor_id </code></pre> <p>but apex said <code>ORA-01789: query block has incorrect number of result columns</code></p> <p>I want the result from it to be different. The first query should have any problem with the second query because they are but doing their own thing.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload