如何匹配联接表和相关表中的列名和值? [英] How to match column names and values from joining and related tables?
本文介绍了如何匹配联接表和相关表中的列名和值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我具有以下数据库结构:
I have the following DB structure:
- id
- 制作
- id
- 名称
- id
- car_id
- feature_id
- 值
我希望能够选择具有所有功能的所有汽车,并返回结果,其中feature.name
作为列名,cars_feature.value
作为值.现在,我可以获取所有功能和所有值,但是我只想出了如何使用group_concat
来实现.
I want to be able to select all cars with all features and return results with feature.name
as the column name and cars_feature.value
as the value. Right now I am able to get all feature and all values but I only figured out how to do that with group_concat
.
我正在寻找以下输出:
car_id car_make color wheels doors
1 Ford blue alloy
2 Audi alloy 3
数据示例: SQLFiddle
Data example: SQLFiddle
推荐答案
以下是我在感谢您的学习经验.
这篇关于如何匹配联接表和相关表中的列名和值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文