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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:45:36+00:00 2026-06-03T18:45:36+00:00

Consider: SELECT * FROM `product` left join category on product.category_id = category.id This query

  • 0

Consider:

SELECT * FROM `product` left join category on product.category_id = category.id

This query works fine. But the problem is, both the product table and the category table have fields named "name" and "id". So when I fetch the result of this query, it gives me only one name and one id, but I want both id’s and name’s.

How can I do this without having to rename the fields?
Is it possible to return with custom names such as product_name and category_name?

  • 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-03T18:45:38+00:00Added an answer on June 3, 2026 at 6:45 pm

    You can add aliases to the fields:

    SELECT
        a.id,
        a.name,
        a.category_id,
        b.id AS catId,
        b.name AS catName
    FROM
        product AS a
    LEFT JOIN
        category AS b ON a.category_id = b.category.id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider This Query: SELECT [Order Details].OrderID, c.CategoryName, COUNT(c.CategoryID) FROM [Order Details] INNER JOIN Products
Consider this simple query: SELECT * FROM table1 JOIN table2 USING(pid) WHERE pid='2' ;
Consider this: //members is a table. String sql=select * from members; Query query =
consider a query that looks something like this: my $query=<<QUERY; select * from foo1
Consider this is a standard Linq from q in SomeQuery select new SomeObject {
(Motivation: Consider a problem where you have to select a sports team from a
Consider the following MySQL statement SELECT AccountNumber, Currency, Balance FROM clients JOIN balances ON
Consider having a matrix. From this matrix I select the same number of elements
Consider the following query in HQL: SELECT m.id, (SELECT (COUNT(*) > 0) FROM SubqueryTable...)
Consider this command, as written here: Command.CommandText = SELECT COUNT(ASSET) AS POSEXISTS FROM POSITIONS

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.