Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a dynamic table which created by breezing form

>   id  record  element title   name    type    value
>   6131    627 6448    Date    date    Calendar    2017-05-15
>   6132    627 6453    Number  num Text    4
>   6129    626 6448    Date    date    Calendar    2017-05-12
>   6130    626 6453    Number  num Text    3
>   6127    625 6448    Date    date    Calendar    2017-05-10
>   6128    625 6453    Number  num Text    1

dynamic table

I want to create a chart by joomla-plotalot components which ask 2 columns result within one select query,like

> 2017-05-15    1 
> 2017-05-12    3 
> 2017-05-10    4

enter image description here

is it possible?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
222 views
Welcome To Ask or Share your Answers For Others

1 Answer

There is a simple solution. Join the table to itself using subqueries with aliases.

SELECT 
  d.`value` AS `date`,
  n.`value` AS `num`
FROM
  (SELECT `record`, `value` FROM MyTable WHERE `name`='date') AS d
  INNER JOIN
  (SELECT `record`, `value` FROM MyTable WHERE `name`='num') AS n
  USING (`record`);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...