Re: [SQL ] 有辦法這樣下嘛

看板Database作者 (我不肥)時間16年前 (2009/08/11 22:12), 編輯推噓2(201)
留言3則, 3人參與, 最新討論串1/1
※ 引述《dream1x (翻桌客 )》之銘言: : 我有兩個資料表A和B分 : ┌──────────────┐ : 表A │user│tourid│..............│ : └──────────────┘ : ┌──────────────────┐ : 表B │tourid│ x │ y │ z │.............│ : └──────────────────┘ : sql要怎麼下才可以找到 表B 然後符合 : A.user='admin'and B.tourid = A.tourid 這個條件的 : select * ....... 我怎麼下都不對 : 先感謝囉 try this select a.user , a.tourid from table_a a, table_b b where a.user='admin' and a.tourid=b.tourid; -- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.166.194.151 ※ 編輯: iamnotfat 來自: 118.166.194.151 (08/11 22:12) ※ 編輯: iamnotfat 來自: 118.166.194.151 (08/11 22:12)

08/11 22:13, , 1F
不確定你的資料庫是否支援alias 但大致上就這樣下
08/11 22:13, 1F

08/11 23:34, , 2F
感謝你 我解決了 只是改成select B from... 就會錯
08/11 23:34, 2F

08/12 20:20, , 3F
是要列出所有B? SELECT B.* FROM ...
08/12 20:20, 3F
文章代碼(AID): #1AWNmpyL (Database)