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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:24:06+00:00 2026-06-01T21:24:06+00:00

I didn’t find anything about that. Here’s my query: SELECT p.*, pa.*, a.* FROM

  • 0

I didn’t find anything about that.

Here’s my query:

SELECT p.*, pa.*, a.*
FROM produit p
LEFT OUTER JOIN produit_attribut pa
ON p.id=pa.id_produit
LEFT OUTER JOIN attribut a
ON a.id=pa.id_attribut
ORDER BY p.id,a.id;

But the problem is that it return columns

with the same name:

+----+------------+-----+------------+-------------+------+-----+----+----+
| id | titre      | desc| id_produit | id_attribut | id   | desc| val| abb|
+----+------------+-----+------------+-------------+------+-----+----+----+
|  1 | Anchois    | Sauc|          1 |           1 |    1 | Nomb| 2  | Nb |  
|  2 | Fromage    | Sauc|          2 |           1 |    1 | Nomb| 2  | Nb |  
|  3 | Mozzarella | Sauc|          3 |           1 |    1 | Nomb| 2  | Nb |  
|  4 | Jambon     | Sauc|          4 |           1 |    1 | Nomb| 2  | Nb |  
|  5 | Roquefort  | Sauc|          5 |           1 |    1 | Nomb| 2  | Nb |  
|  6 | Royale     | Sauc|          6 |           1 |    1 | Nomb| 2  | Nb |  

I’d like to know if there’s a way to rename all fields of a table, something that could look like (I know the following sql doesn’t work):

SELECT p.* as p*, pa.* as pa*, a.* as att*
FROM produit p
LEFT OUTER JOIN produit_attribut pa
ON p.id=pa.id_produit
LEFT OUTER JOIN attribut a
ON a.id=pa.id_attribut
ORDER BY p.id,a.id;

By the way I know that I can do something like:

SELECT
  p.id AS p_id,
  p.titre AS p_titre,
  p.description AS p_description,
  p.prix AS p_prix,
  p.text_detail AS p_text_detail,
  p.img_petite AS p_img_petite,
  p.img_grande AS p_img_grande,
  pa.id_produit AS pa_id_produit,
  pa.id_attribut AS pa_id_attribut,
  a.id AS a_id,
  a.description AS a_description,
  a.valeur AS a_valeur,
  a.abbreviation AS a_abbreviation
FROM produit p
LEFT OUTER JOIN produit_attribut pa
ON p.id=pa.id_produit
LEFT OUTER JOIN attribut a
ON a.id=pa.id_attribut
ORDER BY p_id,a_id;

But I’d like to avoid this.

I’d like the request to be generic, because I’ll use this request in Php and it’s about a generic CRUD component (and nested table).

Is there a way?

  • 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-01T21:24:08+00:00Added an answer on June 1, 2026 at 9:24 pm

    No, there is no way to do that. However, you should try to avoid using * anyway to select columns, so with this refactoring, you get rid of both the * and can add aliases to all columns you need to add them two. Two birds with one stone! 😉

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

Sidebar

Related Questions

I didn't find anything about parsing HTML in the XML::LibXML::Reader documentation. And I tried
I didn't find anywhere whether is possible to query from Db4o all objects implementing
Didn't find any from their website. I mostly just trying to see which one
I didn't find any solution that helped me on the older questions on SO...
I didn't find information about performance issues with auto_ptr and shared_ptr (I use tr1
Didn't find how to do that. What I found was more or less on
I didn't find any tip about DirectX installation at Inno-Setup web site. So, is
I didn't find something good that helps me so I'm asking a question, sorry
I didn't see any questions that asked this previously so here goes: Once you
I didn't find this anywhere - can i tell Play! that a specific controller

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.