SQL - Adding multiple values in 1 column

GeenId

I want to add multiple values of a join query in 1 single column. Is there any way to do that?

Here is a fiddle: http://sqlfiddle.com/#!9/90540/1

Here is a screen of how to result should be like http://i60.tinypic.com/5pk7yg.png "result"

Aleksandar Miladinovic

Ok here is the problem, I (and many people here, I believe) doesn't have a clue what's a point of this query, what the goal you want to achieve with this.

To get desired result you can do something like this...

SELECT CASE WHEN p.id = 1 THEN p.id END AS col1,
       CASE WHEN p.id = 1 THEN p.`value` END AS col2,
       CASE WHEN p.id = 1 THEN (SELECT id FROM site_gender WHERE id = 2) END AS col3, 
       CASE WHEN p.id = 1 THEN (SELECT `value` FROM site_gender WHERE id = 2) END AS col4,
       a.id, a.email 
FROM site_gender AS p
JOIN user_account AS a ON p.id = a.id

but this query doesn't have a much sense, you'll get desired result but i don't know what you can do else with it.

here is the Fiddle for that to see what's happend there...

But if you change a little your table site_gender and add her a column, let's call it parent, than you will have query like this

SELECT p.id, p.value, x.id, x.value, a.id, a.email 
FROM site_gender AS p
INNER JOIN site_gender AS x
ON p.id = x.parent
JOIN user_account AS a 
ON p.id = a.id

Here is SQL fiddle to see how that's look like and work...

point of having parent column is that you can choose which 2 column you want to connect when you have larger table so parent column will store id of column with that column should be connected...

If you have any further question fill free to ask!

GL!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

SQL- Fetching values with multiple values in 1 column

From Dev

SQL Multiple values in one column

From Dev

Adding values in column based on another column of separate table sql

From Dev

oracle sql query finding rows with multiple values in 3rd column matching columns 1 and 2

From Dev

How to update an SQL column that has multiple values

From Dev

SQL - Comparing against multiple values in the same column?

From Dev

MYSQL /SQL multiple alias base on column values

From Dev

How to replace multiple values in a single column with SQL?

From Dev

Multiple values for one column php and sql

From Dev

How to update an SQL column that has multiple values

From Dev

SQL data modeling, a column with multiple values

From Dev

spark scala dataframe adding 1 to all the values in a column

From Dev

Adding column values of 2 or more non distinct rows. SQL

From Dev

How to sum 1 concat column with multiple values in the same column

From Dev

Multiple tables SQL with 1 same column

From Dev

sql server multiple column values in single column by building query

From Dev

Unique values of one column in a multiple column table in oracle sql

From Dev

SQL - Get multiple values when limit 1

From Dev

Adding a column SQL Lite

From Dev

SQL Column with Max Values where seperate column = 1

From Dev

Sql column adding another column

From Dev

Sql column adding another column

From Dev

Adding two column values in SQL Server to populate a third column, can this be done without a trigger/stored procedure?

From Dev

adding two column values in mysql

From Dev

Adding character values of a column in R

From Dev

sql query get multiple values from same column for one row

From Dev

Get multiple values in one column from SQL query

From Dev

SQL autoincrement id with duplicate values and multiple column primary keys?

From Dev

SQL query to find count of multiple occurrences of column values from a table?

Related Related

  1. 1

    SQL- Fetching values with multiple values in 1 column

  2. 2

    SQL Multiple values in one column

  3. 3

    Adding values in column based on another column of separate table sql

  4. 4

    oracle sql query finding rows with multiple values in 3rd column matching columns 1 and 2

  5. 5

    How to update an SQL column that has multiple values

  6. 6

    SQL - Comparing against multiple values in the same column?

  7. 7

    MYSQL /SQL multiple alias base on column values

  8. 8

    How to replace multiple values in a single column with SQL?

  9. 9

    Multiple values for one column php and sql

  10. 10

    How to update an SQL column that has multiple values

  11. 11

    SQL data modeling, a column with multiple values

  12. 12

    spark scala dataframe adding 1 to all the values in a column

  13. 13

    Adding column values of 2 or more non distinct rows. SQL

  14. 14

    How to sum 1 concat column with multiple values in the same column

  15. 15

    Multiple tables SQL with 1 same column

  16. 16

    sql server multiple column values in single column by building query

  17. 17

    Unique values of one column in a multiple column table in oracle sql

  18. 18

    SQL - Get multiple values when limit 1

  19. 19

    Adding a column SQL Lite

  20. 20

    SQL Column with Max Values where seperate column = 1

  21. 21

    Sql column adding another column

  22. 22

    Sql column adding another column

  23. 23

    Adding two column values in SQL Server to populate a third column, can this be done without a trigger/stored procedure?

  24. 24

    adding two column values in mysql

  25. 25

    Adding character values of a column in R

  26. 26

    sql query get multiple values from same column for one row

  27. 27

    Get multiple values in one column from SQL query

  28. 28

    SQL autoincrement id with duplicate values and multiple column primary keys?

  29. 29

    SQL query to find count of multiple occurrences of column values from a table?

HotTag

Archive