whosrdaddy
Vendor
I have 3 tables:
Articles
(id, name, ...)
sample data
(1, 'intel E8400')
OrderLines
(id, OrderId, ArticleId, number_of_articles, price...)
sample data
(1, 1, 1, 2, 10)
(2, 1, 1, 2, 20)
Serials
(id, ArticleId, OrderId, serialnumber)
sample data
(1, 1, 1, '1234')
(2, 1, 1, '4567')
(3, 1, 1, '8901')
(4, 1, 1, '2345')
for my invoice I need to get the serialnumbers for each orderline.
Based on the sample data, I want this output
2x Intel 8400, (Serials: 1234, 4567)
2x Intel 8400, (Serials: 8901, 2345)
This is what I have at the moment:
And produces this output:
[tt]
ArticleId x sn
--------- - --
1 2 1234,4567,8901,2345
[/tt]
And I want
[tt]
ArticleId x sn
--------- - --
1 2 1234,4567
1 2 8901,2345
[/tt]
How can I do this?
Greetings,
Daddy
-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
Articles
(id, name, ...)
sample data
(1, 'intel E8400')
OrderLines
(id, OrderId, ArticleId, number_of_articles, price...)
sample data
(1, 1, 1, 2, 10)
(2, 1, 1, 2, 20)
Serials
(id, ArticleId, OrderId, serialnumber)
sample data
(1, 1, 1, '1234')
(2, 1, 1, '4567')
(3, 1, 1, '8901')
(4, 1, 1, '2345')
for my invoice I need to get the serialnumbers for each orderline.
Based on the sample data, I want this output
2x Intel 8400, (Serials: 1234, 4567)
2x Intel 8400, (Serials: 8901, 2345)
This is what I have at the moment:
Code:
SELECT s.ArticleId, o.number_of_articles AS x, GROUP_CONCAT(s.serialnumber) AS sn
FROM Serials s
INNER JOIN Ordelines o ON o.OrderId = s.OrderId AND o.ArticleId = s.ArticleId
WHERE o.OrderId = 1
And produces this output:
[tt]
ArticleId x sn
--------- - --
1 2 1234,4567,8901,2345
[/tt]
And I want
[tt]
ArticleId x sn
--------- - --
1 2 1234,4567
1 2 8901,2345
[/tt]
How can I do this?
Greetings,
Daddy
-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!