2011-02-25 134 views
0

我的表-1有20列,而表-2有15列。這裏我想通過用戶ID加入兩個表格。 我用這個波紋管查詢只在mysql中選擇特定的列

SELECT * FROM table_checkout_bidpack as t1 inner JOIN table_user_information 
as t2 ON t1.user_id=t2.user_id 

此查詢選擇35列,但我需要在第二個表

我知道這項工作列(USER_NAME)選擇

select t1.col1,t1.col2,t1.col3,t1.col4,.....,t2.user_name 
FROM table_checkout_bidpack as t1 inner JOIN table_user_information 
as t2 ON t1.user_id=t2.user_id 

這看起來很大任何其他方式做到這一點

+0

所以你想從t1的所有列,但只有t2從user_name? – 2011-02-25 04:56:30

回答

4
select t1.*,t2.user_name 
FROM table_checkout_bidpack as t1 inner JOIN table_user_information 
as t2 ON t1.user_id=t2.user_id 
+0

哦,我瘋了,坦克 – Gowri 2011-02-25 05:18:36

0
select t1.*,t2.user_name 
FROM table_checkout_bidpack as t1 inner JOIN table_user_information 
as t2 ON t1.user_id=t2.user_id 

*是通配符選擇器,它本身將匹配所有表中的所有列,但如果以table.作爲前綴,它將僅匹配該表中的列。