簡體   English   中英

從兩個表和一個where條件中選擇

[英]Selecting from two tables and a where condition

我有兩個表:

Images:
id | name | width

Extra:
id | width | extra

如何從圖像中選擇所有內容,並為每行從額外表中選擇“額外”,其中images.width為<= extra.width?

例如

Images:
id | name | width
1  | a.jpg| 100
2  | b.jpg| 200
3  | c.jpg| 5
Extra:
id | width | extra
1  | 100   | 'test'
2  | 200   | 'normal'
3  | 50    | 'better'

所以:

  • a.jpg需要額外的“測試”。
  • b.jpg會有額外的“正常”。
  • c.jpg會有更好的效果。

試試這個查詢

SELECT *
FROM Images JOIN Extra ON Images.width<=Extra.width

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM