Hallo zusammen!
Ich habe in meiner DB drei Tabellen, aus denen ich eine View erstellen möchte:
Meine SELECT-Abfrage:
[highlight=sql]SELECT
articles.id,
books.id AS bookid,
books.name,
books.isbn,
drinks.id AS drinkid,
drinks.name,
drinks.color
FROM
articles
JOIN books ON books.article_id = articles.id
JOIN drinks ON drinks.article_id = articles.id[/highlight]
Ergebnistabelle:
id
bookid
name
drinkid
name
color
Die Spalte "name" würde ich aber gerne nur einmal haben. Wie muss ich dazu meine Abfrage verändern?
Danke
Ich habe in meiner DB drei Tabellen, aus denen ich eine View erstellen möchte:
articles
id (int)
books
id (int)
name (varchar)
isbn (varchar)
article_id (int) -> articles.id
drinks
id (int)
name (varchar)
color (varchar)
article_id (int) -> articles.id
id (int)
books
id (int)
name (varchar)
isbn (varchar)
article_id (int) -> articles.id
drinks
id (int)
name (varchar)
color (varchar)
article_id (int) -> articles.id
[highlight=sql]SELECT
articles.id,
books.id AS bookid,
books.name,
books.isbn,
drinks.id AS drinkid,
drinks.name,
drinks.color
FROM
articles
JOIN books ON books.article_id = articles.id
JOIN drinks ON drinks.article_id = articles.id[/highlight]
Ergebnistabelle:
id
bookid
name
drinkid
name
color
Die Spalte "name" würde ich aber gerne nur einmal haben. Wie muss ich dazu meine Abfrage verändern?
Danke
Comment