开发者

How to get data 3 tables?

can u please show me how to query开发者_开发问答 3 tables using *? thanks


You need to do a join on the tables in order to get the columns of all of them.

Warning: using * to get all columns is bad practice. You should qualify (name) all the columns you need.

Here is an example:

SELECT * 
FROM table1 t1
INNER JOIN table2 t2
  ON t1.key2 = t2.key2
INNER JOIN table3 t3
  ON t1.key3 = t3.key3


One way you probably don't like:

SELECT *
FROM table1, table2, table3

You have to give way more information.

This generates the Cartesian product of all the three tables.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜