Grab from table values

xCloudx8

This is my table dataset:

col1 col2 col3 col4
 2    7    5    3
 11   18    31  7  

Those are id's and need to use them as id to grab the name at them associated. if i do:

select table1.name from table1,table2 where table2.id = 1

Gives me the name associated to id 1. I want to automatically grab the names based on the id's in my table in this form.

  name1     name2       name3    name4
 name_id2  name_id7   name_id5 name_id3

There is a way to obtain this?

---------AS ASKED EXAMPLE

Table1:

col2 col3 col4
 2     3    4  
 2     5    6

Table2:

nome  id
 all   1
 dis1  2
 dis3  3
 dis4  4
 dis5  5
 dis6  6

My_result:

col2 col3 col4
 dis2 dis3 dis4
 dis2 dis5 dis6
Marcin C.

Try this code:

SELECT T2_1.nome as col2, T2_2.nome as col3, T2_3.nome as col4
FROM Table1
LEFT JOIN Table2 as T2_1 on T2_1.ID=Table1.col2
LEFT JOIN Table2 as T2_2 on T2_2.ID=Table1.col3
LEFT JOIN Table2 as T2_3 on T2_3.ID=Table1.col4

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Grab one row from a table

From Dev

How do I grab info from one table while still adding values?

From Dev

How do I grab info from one table while still adding values?

From Dev

Grab values of an attribute from all elements in jQuery

From Dev

How to Grab multiple values from checkboxes with Jquery

From Dev

Grab table from URL in Google App Script

From Dev

grab column elements from table header

From Dev

Grab Data on the Fly from Table HTML

From Dev

grab values from checkboxes in contact form and $_POST email

From Dev

grab values from checkboxes in contact form and $_POST email

From Dev

Can't grab values from drop down on change for URL

From Dev

How to grab values from unformatted string in ios objective-c?

From Dev

Grab value from another table via foreign key

From Dev

How to grab multiple rows from a table with the same value for a foreign key

From Dev

MYSQL and PHP loop and grab just one item from a joint table?

From Dev

How do I grab the most recent price change from table

From Dev

How to grab data from another table with this relationship setup?

From Dev

how to grab the not equal row from joined table in mysql?

From Dev

How to grab data from table with divs and inputs inside cells?

From Dev

How to grab all tr elements from a table and click on a link?

From Dev

Insert values from A table to A table

From Dev

Group and values from table

From Dev

querying values from the table

From Dev

Grab Dynamically Appended Values

From Dev

Grab multiple radio values

From Dev

Grab multiple radio values

From Dev

Python beautifulsoup grab table

From Dev

Grab Table Element in Javascript

From Dev

How can I grab the rows from a specific table using an XPATH expression - mine seems to grab all the rows in the document

Related Related

  1. 1

    Grab one row from a table

  2. 2

    How do I grab info from one table while still adding values?

  3. 3

    How do I grab info from one table while still adding values?

  4. 4

    Grab values of an attribute from all elements in jQuery

  5. 5

    How to Grab multiple values from checkboxes with Jquery

  6. 6

    Grab table from URL in Google App Script

  7. 7

    grab column elements from table header

  8. 8

    Grab Data on the Fly from Table HTML

  9. 9

    grab values from checkboxes in contact form and $_POST email

  10. 10

    grab values from checkboxes in contact form and $_POST email

  11. 11

    Can't grab values from drop down on change for URL

  12. 12

    How to grab values from unformatted string in ios objective-c?

  13. 13

    Grab value from another table via foreign key

  14. 14

    How to grab multiple rows from a table with the same value for a foreign key

  15. 15

    MYSQL and PHP loop and grab just one item from a joint table?

  16. 16

    How do I grab the most recent price change from table

  17. 17

    How to grab data from another table with this relationship setup?

  18. 18

    how to grab the not equal row from joined table in mysql?

  19. 19

    How to grab data from table with divs and inputs inside cells?

  20. 20

    How to grab all tr elements from a table and click on a link?

  21. 21

    Insert values from A table to A table

  22. 22

    Group and values from table

  23. 23

    querying values from the table

  24. 24

    Grab Dynamically Appended Values

  25. 25

    Grab multiple radio values

  26. 26

    Grab multiple radio values

  27. 27

    Python beautifulsoup grab table

  28. 28

    Grab Table Element in Javascript

  29. 29

    How can I grab the rows from a specific table using an XPATH expression - mine seems to grab all the rows in the document

HotTag

Archive