【发布时间】:2018-02-18 14:42:07
【问题描述】:
列 t.name(genre) 显示许多相同的值我试图让它工作,但我没有成功..
这是我的 SQL
select o.id, b.title, a.firstName, a.lastName,
b.noOfPages, b.price, group_concat(t.name) as 'genre'
from author a,book_author ba, book_type bt,orders o,type t, book b, order_list ol
where ol.book_fk = b.id
and bt.book_fk = b.id
and bt.type_fk = t.id
and ba.author_fk = a.id
and ba.book_fk = b.id
and ol.orders_fk = '74'
GROUP BY ol.id
图片显示列类型查询返回多少个值
【问题讨论】:
-
提示:从不在
FROM子句中使用逗号。 始终使用正确、明确的JOIN语法。 -
请编辑您的问题并向我们展示示例数据和预期输出。请注意,您使用
GROUP BY没有多大意义,因为您选择的是非聚合列,而title甚至可能不是其自己表中的主键。 -
嗨。你的问题是什么?当您编辑您的帖子以询问它时,请确保您告诉我们您的查询应该返回什么,以及为什么您得到的是错误/有问题的。 minimal reproducible example 请。 PS请use text, not images/links, for text (including code, tables & ERDs)。使用图片只是为了方便补充文本和/或无法在文本中给出的内容。
-
我编辑了它(列 t.name 显示了许多相同的值,我试图让它工作,但我没有成功..)
-
图片显示有多少列类型返回值
标签: php mysql sql phpmyadmin