PHP MySQL 对值进行计数和排序
我是新来的。如果我在错误的区域提出问题或忽略了之前搜索中的某些内容,从而违反了某种协议,我深表歉意。
我有一个名为 Art2011 的表格。
我正在三列中收集数据,并希望合并并计算类似的值。
painting1 painting2 painting3
-----------------------------------------
image6 image4 image3
image4 image1 image4
image8 image1 image3
image2 image9 image6
image6 image4 image3
image4 image1 image4
image8 image1 image3
image2 image9 image6
我如何在 php 中查询、计数和显示结果,看起来像这样?
image1 = 4
image2 = 2
image3 = 4
image4 = 5
etc...
先感谢您! 迈克尔
I'm new here. In case I'm breaking some kind of protocol by asking the question in the wrong area or overlooking something in a previous search I apologize.
I have a table titled Art2011.
I am collecting data in three columns and would like to combine and count like values.
painting1 painting2 painting3
-----------------------------------------
image6 image4 image3
image4 image1 image4
image8 image1 image3
image2 image9 image6
image6 image4 image3
image4 image1 image4
image8 image1 image3
image2 image9 image6
How would I query, count and display the results in php to look like this?
image1 = 4
image2 = 2
image3 = 4
image4 = 5
etc...
Thank you in advance!
Michael
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试
Try
对于每张图像,您可以使用以下查询来获取计数:
select count(1) from Art2011 where Painting1 = 'image1' or Painting2 = 'image1' or Painting3 = 'image1'
For each image, you can use this query to get the count:
select count(1) from Art2011 where painting1 = 'image1' or painting2 = 'image1' or painting3 = 'image1'
添加到 @ain 的帖子:
Adding to @ain's post :