简体   繁体   中英

SQL query involving data from multiple tables

I am really new to SQL & it would be really helpful if somebody can help with one simple query that I am struggling to write.

list ( plid, fid )

files ( fid, filename )

I want to get the fid & filename from the above tables where plid=3. The steps would be 1) Get the fid values from table "list" where plid=x 2) Get the filename from "files" for all the matched fid in table "list".

这正是您需要JOIN语句的地方:

SELECT list.fid, files.filename FROM list INNER JOIN files ON files.fid = list.fid WHERE files.plid = 3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM