开发者

How to get data 3 tables?

开发者 https://www.devze.com 2022-12-21 21:25 出处:网络
can u please show me how to query开发者_开发问答 3 tables using *? thanksYou need to do a join on the tables in order to get the columns of all of them.

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

精彩评论

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