Advertisement
Guest User

SQL til udtræk af data

a guest
Sep 15th, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.97 KB | None | 0 0
  1. SELECT
  2.   `bil_aargang`,
  3.   `land_navn`,
  4.   `model_navn`,
  5.   `maerke_navn`,
  6.   `braendstof_navn`,
  7.   COALESCE(`bd1`.`data_float`, `bd1`.`data_int`, `bd1`.`data_varchar`) AS `motor`,
  8.   COALESCE(`bd2`.`data_float`, `bd2`.`data_int`, `bd2`.`data_varchar`) AS `heste`,
  9.   COALESCE(`bd3`.`data_float`, `bd3`.`data_int`, `bd3`.`data_varchar`) AS `acceleration`
  10. FROM
  11.   `bil` AS `b`
  12.   LEFT JOIN `bil_data` AS `bd1` ON `b`.`bil_id`=`bd1`.`bil_id` RIGHT JOIN `attribut` AS `a1` ON `a1`.`attribut_id`=`bd1`.`attribut_id` AND `a1`.`attribut_navn`='motor'
  13.   LEFT JOIN `bil_data` AS `bd2` ON `b`.`bil_id`=`bd2`.`bil_id` RIGHT JOIN `attribut` AS `a2` ON `a2`.`attribut_id`=`bd2`.`attribut_id` AND `a2`.`attribut_navn`='heste'
  14.   LEFT JOIN `bil_data` AS `bd3` ON `b`.`bil_id`=`bd3`.`bil_id` RIGHT JOIN `attribut` AS `a3` ON `a3`.`attribut_id`=`bd3`.`attribut_id` AND `a3`.`attribut_navn`='acceleration'
  15.   NATURAL JOIN `model`
  16.   NATURAL JOIN `maerke`
  17.   NATURAL JOIN `braendstof`
  18.   NATURAL JOIN `land`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement