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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:04:52+00:00 2026-06-11T22:04:52+00:00

I have the following two tables: foo: ID NUMBER(38) DATA VARCHAR2(10) bar: ID NUMBER(38)

  • 0

I have the following two tables:

foo:

ID     NUMBER(38)
DATA   VARCHAR2(10)

bar:

ID     NUMBER(38)
FOO_ID NUMBER(38)
DATA   VARCHAR2(10)

When using PDO to issue the following query:

SELECT * FROM foo f INNER JOIN bar b ON (f.id = b.foo_id)

Is there any way to get back all of the columns from the join in some kind of auto-aliased format (e.g. “FOO.ID”, “FOO.DATA”, “BAR.ID”, etc.) so that I don’t need to specify and alias every single column in the query?

I’ve read all of the documentation on the various fetch modes, and experimented with most of the flags/options, but still can’t seem to find what I’m looking for.

Update:

Using PDO::FETCH_ASSOC, the columns from foo seem to be overwritten by the columns from bar:

array(3) {
  ["ID"]=>
  string(1) "1"
  ["DATA"]=>
  string(5) "bar 1"
  ["FOO_ID"]=>
  string(1) "1"
}

Using PDO::FETCH_NUM, the columns from both foo and bar appear, in order, but without any way to identify which columns came from which tables, except by knowing the number of columns in each table and exact order of those columns (error prone):

array(5) {
  [0]=>
  string(1) "1"
  [1]=>
  string(5) "foo 1"
  [2]=>
  string(1) "1"
  [3]=>
  string(1) "1"
  [4]=>
  string(5) "bar 1"
}

Using PDO::FETCH_BOTH, we seemingly run into the same problems as PDO::FETCH_ASSOC and PDO::FETCH_NUM combined, and create a horribly unintelligible result set:

array(8) {
  ["ID"]=>
  string(1) "1"
  [0]=>
  string(1) "1"
  ["DATA"]=>
  string(5) "bar 1"
  [1]=>
  string(5) "foo 1"
  [2]=>
  string(1) "1"
  ["FOO_ID"]=>
  string(1) "1"
  [3]=>
  string(1) "1"
  [4]=>
  string(5) "bar 1"
}

IDEALLY, the result set should look similar to this:

array(5) {
  ["FOO.ID"]=>
  string(1) "1"
  ["FOO.DATA"]=>
  string(5) "foo 1"
  ["BAR.ID"]=>
  string(1) "1"
  ["BAR.FOO_ID"]=>
  string(1) "1"
  ["BAR.DATA"]=>
  string(5) "bar 1"
}
  • 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-11T22:04:54+00:00Added an answer on June 11, 2026 at 10:04 pm

    There appears to be no way to do this behind the curtains. Explicit aliasing is the only way.

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

Sidebar

Related Questions

Let's assume that I have two tables... Foo and Bar. They contain the following
1I have the following two tables (sample data) and need to be able to
I am using VB.NET with LINQ to MS SQL. I have two following tables.
I have the following query: SELECT * from foo where timestamp = (select max(timestamp)
I have two tables of the following form (i.e., every foo is linked to
I have the following query: SELECT location, step, COUNT(*), AVG(foo), YEAR(start), MONTH(start), DAY(start) FROM
I have two 2 tables in my database Table: Foo Table: Bar ----------------- ---------------------
I have the following two tables: TABLE: area *City_ID *Number Name -------- ------- ----
I have two MySQL tables, here's how they are structured: table foo( foo_id varchar(32),
I have two tables, we'll call them Foo and Bar , with a one

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.