作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 table 是
user: userID - userLogocontent: userID - contentID - contentImagepromo: promoID - userID - promoImage
this is my query
SELECT userID,userLogo FROM user
WHERE userID=4
UNION ALL
SELECT userID,contentImage FROM content
WHERE userID=4
UNION ALL
SELECT userID,promoImage FROM promo
WHERE userID=4
ORDER BY userID
结果是
userID userLogo4 ../images/user/000004.jpg 4 ../images/content/000003.jpg4 ../images/content/000004.jpg4 ../images/content/000005.jpg4 ../images/content/000006.jpg4 ../images/promo/000003.jpg4 ../images/promo/000004.jpg4 ../images/promo/000005.jpg
得到的结果和我想要的很相似,但是列标题不是我想要的
还有,关于 php.. 是否可以使用上面的查询来取消链接结果中的所有图像?
还有一个问题,讲效率,我的查询对数据库造成很大的负载吗?如果是,请给出建议或任何解决方案。
谢谢!
最佳答案
您可以使用第三列,以便您可以检查符合条件的图像类型
SELECT
userID,
userLogo,
'userLogo' as Type
FROM user
WHERE userID=4
UNION ALL
SELECT
userID,
contentImage,
'contentImage' as Type
FROM content
WHERE userID=4
UNION ALL
SELECT
userID,
promoImage,
'promoImage' as Type
FROM promo
WHERE userID=4
ORDER BY userID
关于php - 我的 UNION ALL 查询需要建议,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20064800/
我是一名优秀的程序员,十分优秀!