作者iamnotfat (我不肥)
看板Database
標題Re: [SQL ] 有辦法這樣下嘛
時間Tue Aug 11 22:12:00 2009
※ 引述《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)
→ iamnotfat:不確定你的資料庫是否支援alias 但大致上就這樣下 08/11 22:13
推 dream1x:感謝你 我解決了 只是改成select B from... 就會錯 08/11 23:34
推 rushcat:是要列出所有B? SELECT B.* FROM ... 08/12 20:20