我有一张MySQL照片表,并将它们的尺寸存储在一个varchar字段中,即。 “1024×768”。有没有办法选择上面或等于给定尺寸的照片而不必修改表格分别存储'height'和'width'?
由于
答案 0 :(得分:1)
SELECT *
FROM photos
WHERE CAST(SUBSTR(dimensions, 1, LOCATE("x", dimensions)-1) as NUMBER) > @height
AND CAST(SUBSTR(dimensions, LOCATE("x", dimensions)+1)) as NUMBER) > @width