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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:20:33+00:00 2026-05-31T20:20:33+00:00

I have 2 tables with some columns and another table that I want its

  • 0

I have 2 tables with some columns and another table that I want its rows as columns to the view.

table1
uid|atr1|atr2|atr3

table2
uid|col1|col2

profile_fields(this is a dynamic table, thats why its rows)
fid|name

profile_values
fid|uid|value

so In the end I want a view like that and 1 row for each uid:

View
uid|atr1|atr2|atr3|col1|col2|name(all row names here from profile_Fields)|

and 1 entry row for each uid with all its user data and values

I dont understand how to make the view with the profile_fields because it has rows and not columns. It worked without this table in the first place but can’t make it work like I explained above.

  • 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-31T20:20:35+00:00Added an answer on May 31, 2026 at 8:20 pm

    You should use a pivot table mechanism, e.g. –

    SELECT pv.*,
      MAX(IF(pf.field = 'Category1', pv.value, NULL)) AS Category1,
      MAX(IF(pf.field = 'Category2', pv.value, NULL)) AS Category2,
      MAX(IF(pf.field = 'Category3', pv.value, NULL)) AS Category3
    FROM profile_values pv
      LEFT JOIN profile_fields pf
        ON pv.fid = pf.fid
    GROUP BY uid
    

    Then join this query to your tables.

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

Sidebar

Related Questions

I have a table that, some of its columns are unknown at compile time.
i have made columns in some of the tables encrypted in sql server 2008.
I have some data I am querying. The table is composed of two columns
I have some table DOCUMENTS that have a column TYPE_ID and a table named
I have a table with a column 'A'. Some rows have 14 digits for
I have some tables that I build as a part of my report rollup.
I have some tables that represent various types. They usually just consist of an
i have some SQL code that is inserting values from another (non sql-based) system.
We have a SQL Server database table that consists of user id, some numeric
I need to create a table that has some fields that another one has

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.