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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:06:35+00:00 2026-05-27T00:06:35+00:00

How would I query the following? User.name and Groups.description, from the User table and

  • 0

How would I query the following?

User.name and Groups.description, 
from the User table and Groups table, 
where User.id_user = User_Group.id_user, and Groups.id_groups = User_Group.id_groups 

I read about UNION and Joins, but UNION requires the tables to have the same number of columns, while the JOINs seem to work only with 2 tables?? Is it possible to combine UNION and Joins?

SELECT User.Name
FROM User
FULL JOIN User_Groups
ON User.Id_user= User_Groups.Id_user
UNION
SELECT Group.Description
FROM Group
FULL JOIN User_Groups
ON Group.Id_group= Groups.Id_group

Would the above code be right??

  • 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-27T00:06:36+00:00Added an answer on May 27, 2026 at 12:06 am

    Try this simplified query:

    SELECT u.Name
    FROM   User u
    JOIN   User_Groups USING (Id_user)
    
    UNION  ALL
    SELECT g.Description
    FROM   Group g
    JOIN   User_Groups USING (Id_group)
    
    • Use UNION ALL instead of UNION, because UNION would eliminate any rows with the same values.

    • The result of a UNION has only one header, the column names are taken from the fist SELECT in the query. So the column name will be “Name” in your case.

    • USING is just a syntactical simplification for ON when the joining columns share the same name(s) and occur only once left and right of the join.

    • Table aliases User AS u or simply User u simplify later references in the code.

    • You can JOIN as many tables as you like, this is not limited to two tables. I suspect, what you really want is this:

    SELECT u.Name, g.Description
    FROM   User u
    JOIN   User_Groups USING (Id_user)
    JOIN   Group g USING (Id_group)
    
    • But there is no FULL [OUTER] JOIN in MySQL. Other RDBMS have that, like PostgreSQL. Read here.
      I suspect, that’s not what you wanted to begin with and replaced it with a plain [INNER] JOIN. Read more in the manual here.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would I go about executing the following Hibernate query using the criteria API.
I have following query: var result = ( from role in db.Roles join user
Why would the following query return Error converting data type varchar to bigint? Doesn't
Just wondering how the following sql query would look in linq for Entity Framework...
How would the following sql statement translate to a linq query? select ID, Price,
I would like to create a query that returns rows in the following format:
I would like to pass a MYSQL query via Coldfusion the following date: 03/13/2010
Using MySQL syntax, how would I write a query to return the following (I
Which query would run faster? SELECT * FROM topic_info LEFT JOIN topic_data ON topic_info.id
How would you query Picasa from a Google App Engine app? Data API or

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.