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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:15:18+00:00 2026-05-18T22:15:18+00:00

I have 4 tables and this query SELECT tag.id, title FROM tag LEFT JOIN

  • 0

I have 4 tables and this query

SELECT tag.id, title
FROM tag
LEFT JOIN tag_map ON ( tag.id = tag_map.tag_id ) 
LEFT JOIN post ON ( post.id = post_id ) 
LEFT JOIN game ON ( game.id = post_id ) 
LEFT JOIN video ON ( video.id = post_id ) 
WHERE tag_slug =  "blizzard"
ORDER BY tag_map.post_type

The problem in this query is that the 3 tables on the left join statement all have a title column. Because of this I’m getting the “Column ‘title’ in field list is ambiguous” error.

How can I handle this so that the query shows the related title field for each row..

  • 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-18T22:15:18+00:00Added an answer on May 18, 2026 at 10:15 pm

    Based on the additional information supplied in a comment to another response, it appears that the a DIFFERENT title field needs to be selected depending on the post_type, with post_types corresponding to the post, game, and video tables.

    I’ll assume that post_type is a one character text column.

    You can do that in two ways, with LEFT JOIN or UNION.

    SELECT tag.id, 
    CASE post_type 
       WHEN 'P' THEN post.title 
       WHEN 'V' THEN video.title 
       WHEN 'G' THEN game.title
    END CASE
    FROM tag
    LEFT JOIN tag_map ON ( tag.id = tag_map.tag_id ) 
    LEFT JOIN post ON ( post.id = post_id ) 
    LEFT JOIN game ON ( game.id = post_id ) 
    LEFT JOIN video ON ( video.id = post_id ) 
    WHERE tag_slug =  "blizzard"
    ORDER BY tag_map.post_type
    

    However, a UNION solution might be clearer:

    SELECT tag.id, post_type, title 
      FROM tag_map INNER JOIN post ON tag_map.post_id = post.id
    UNION ALL
    SELECT tag.id, post_type, title 
      FROM tag_map INNER JOIN game ON tag_map.post_id = game.id
    UNION ALL
    SELECT tag.id, post_type, title 
      FROM tag_map INNER JOIN video ON tag_map.post_id = video.id
    WHERE tag_slug =  "blizzard"
    ORDER BY tag_map.post_type
    

    (Note, I simplified the answers slightly because it’s not clear to me the relation between tag and tag_map, you might need to introduce both tables into the SELECTS).

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

Sidebar

Related Questions

i have this 4 tables: posts{id,post,date} comment{id, user_id,post_id, comment, date} tag_post{tag_id,post_id} users{user_id, email,pwd,username} i
I have a query like this: SELECT TABLE_NAME, COLUMN_NAME, IS_NULLABLE, DATA_TYPE FROM MY_DB.INFORMATION_SCHEMA.COLUMNS WHERE
I have 2 tables: posts tags Tags table is structured like this: post_id tag
I'm having trouble optimizing this query: SELECT a.id FROM a JOIN b ON a.id=b.id
I have a multi-table query, similar to this (simplified version) SELECT columns, count(table2.rev_id) As
I have three tables. This query will write down the right answer (x-lines for
Just need some help to refine this query if possible. SELECT * FROM E_Associates
I have this sql that gets the posts by the terms: SELECT * FROM
i have these two tables , s(id,firstname,lastname,mydate,mount,sh) users(uid,email,password,nameoffice) and this query $sql=SELECT s.id,s.firstname,s.lastname,s.mydate,s.mount,users.nameOffice FROM
I have the following query select count(trade_sid), shortcode from trade where trade.trade_date <= sysdate

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.