I have two tables:
Images:
id | name | width
Extra:
id | width | extra
How can I select all from images and for each row, select 'extra' from the extra table where images.width is <= extra.width?
Eg
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'
So:
Try this query
SELECT *
FROM Images JOIN Extra ON Images.width<=Extra.width
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.