2013-07-02 31 views
1

我得到了table1table2,並且需要從每個表中獲取數據。從兩個不同的表中選擇數據而不使用連接

表1

"id" "name"  "description" 
"1"  "Windows" "Microsoft Windows 8" 

表2

"id" "type" "name"    "description" 
"1" "22" "Microsoft Windows" "Microsoft Windows 8 Home" 
"2" "2" "Not an Edit"  "Not an Edit" 

我做選擇這樣

select table1.name, table1.description, 
table2.name, table2.description 
from table1,table2 
where table2.id=table1.id and table2.`type`=22; 

使用將內連接變得更快或更有效地選擇一些時500+一次行嗎?

我見過大多數使用內部連接的例子來做到這一點。

+2

和問題是什麼?的 – Aguardientico

+0

可能重複[ANSI與非ANSI SQL JOIN語法(http://stackoverflow.com/questions/1599050/ansi-vs-non-ansi-sql-join-syntax) –

+0

我不知道你在哪裏正在尋找像這樣的內部連接的例子。只需使用一個明確的'INNER JOIN' – Scotch

回答

0

你可以做這樣的..

select table1.name, table1.description, 
table2.name, table2.description 
from table1 inner join Table2 on table2.id=table1.id and table2.`type`=22 
1

這是無連接的正確答案

select t1.*,t2.* from t1,t2 where t1.id=t2.id; 
相關問題