How can I select from different tables in one MySQL query?

user2429282
table1
id firstname
-------------
1 Elon
2 Steve


table2
id profession
-------------
1 Entrepreneur
2 Engineer


table3
firstname profession
-------------
1 2
2 1

Need result:

firstname profession
-------------
Elon Engineer
Steve Entrepreneur

How can I select from different tables in one MySQL query? How can I select from different tables in one MySQL query?

Jens

This statement should give you the result you needed.

select t1.firstname, t2.profession from table1 t1 join table3 t3 on t1.id=t3.firstname join table2 t2 on t3.profession = t2.profession

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I update two different tables in one query?

From Dev

MySQL How can I select data from two tables so that rows from the second one overwrote those from the first one?

From Dev

MySQL query to select one table based on values from two different tables.

From Dev

How can I do this in one MySQL Select query, I want to lose the foreach loop and the second select query?

From Dev

How can I select from items from two tables with one item only have one value

From Dev

mysql combine select from 3 tables with one different column

From Dev

MySQL: Get the values from different tables in one query?

From Dev

how do i merge 3 select statements from different tables into 1 specific query?

From Dev

how do i merge 3 select statements from different tables into 1 specific query?

From Dev

Join multiple tables, select counts from different tables and group by one column in one query

From Dev

How to make 2 different joins in one query (3 tables) on mysql

From Dev

How do I select related data from different tables and use it to show trend in mysql and php?

From Dev

PHP can't select anything from only one of the mysql tables

From Dev

How to select from 2 different tables and order them by one column?

From Dev

How can I collectively select 100 rows from 3 different tables?

From Dev

How can I write a SQL query to do a full text search from multiple tables and then join the results comming from different tables?

From Dev

How can I show values from two tables with one SELECT command in SQL?

From Dev

How can I make a list of multiple attributes from different tables? MySQL

From Dev

How can I connect data from two different tables in mysql (LEFT JOIN)?

From Dev

How to select a value that can come from two different tables?

From Dev

How can I select both specific columns and wildcards in one mysql query

From Dev

How do I display data from different tables with a single query?

From Dev

How do I use more "select query" with Mysql to get result from different table

From Dev

Get values from different tables in one query

From Dev

How can I store the same data in two different mySQL tables?

From Dev

How can I create categories with different options of it in mysql tables

From Dev

How can I select two different values from another table using only a single query?

From Dev

How can I select * from table, but cast one of the columns to a different datatype?

From Dev

How can I return rows from an SQL query where one unique ID satisfies conditions in different rows?

Related Related

  1. 1

    How can I update two different tables in one query?

  2. 2

    MySQL How can I select data from two tables so that rows from the second one overwrote those from the first one?

  3. 3

    MySQL query to select one table based on values from two different tables.

  4. 4

    How can I do this in one MySQL Select query, I want to lose the foreach loop and the second select query?

  5. 5

    How can I select from items from two tables with one item only have one value

  6. 6

    mysql combine select from 3 tables with one different column

  7. 7

    MySQL: Get the values from different tables in one query?

  8. 8

    how do i merge 3 select statements from different tables into 1 specific query?

  9. 9

    how do i merge 3 select statements from different tables into 1 specific query?

  10. 10

    Join multiple tables, select counts from different tables and group by one column in one query

  11. 11

    How to make 2 different joins in one query (3 tables) on mysql

  12. 12

    How do I select related data from different tables and use it to show trend in mysql and php?

  13. 13

    PHP can't select anything from only one of the mysql tables

  14. 14

    How to select from 2 different tables and order them by one column?

  15. 15

    How can I collectively select 100 rows from 3 different tables?

  16. 16

    How can I write a SQL query to do a full text search from multiple tables and then join the results comming from different tables?

  17. 17

    How can I show values from two tables with one SELECT command in SQL?

  18. 18

    How can I make a list of multiple attributes from different tables? MySQL

  19. 19

    How can I connect data from two different tables in mysql (LEFT JOIN)?

  20. 20

    How to select a value that can come from two different tables?

  21. 21

    How can I select both specific columns and wildcards in one mysql query

  22. 22

    How do I display data from different tables with a single query?

  23. 23

    How do I use more "select query" with Mysql to get result from different table

  24. 24

    Get values from different tables in one query

  25. 25

    How can I store the same data in two different mySQL tables?

  26. 26

    How can I create categories with different options of it in mysql tables

  27. 27

    How can I select two different values from another table using only a single query?

  28. 28

    How can I select * from table, but cast one of the columns to a different datatype?

  29. 29

    How can I return rows from an SQL query where one unique ID satisfies conditions in different rows?

HotTag

Archive