mysql - Fetch data from two different tables in one query -


on webserver there databse following 2 tables:

tbl_friend                                    tbl_colleague  | id | name | first name | place |            | id | name | first name | place |  ----------------------------------            ---------------------------------- |  1 | xxxx | xxxxxxxxxx |   1   |            |  1 | aaaa | aaaaaaaaaa |   1   | |  2 | yyyy | yyyyyyyyyy |   2   |            |  2 | bbbb | bbbbbbbbbb |   3   | |  3 | zzzz | zzzzzzzzzz |   1   |            |  3 | cccc | cccccccccc |   4   | 

now want fetch persons tbl_friend , tbl_colleague life in place 1. have data both tables , here problem: how can fetch data 2 different tables in 1 query? result should this:

| id | name | first name | place | ---------------------------------- |  1 | xxxx | xxxxxxxxxx |   1   | |  1 | aaaa | aaaaaaaaaa |   1   | |  3 | zzzz | zzzzzzzzzz |   1   | 

can use from tbl_friend | tbl_colleague or else? or have use join this?

try this:

select id, name, first name, place tbl_friend   place= 1 union select id, name, first name, place tbl_colleague   place= 1 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -