MySQL Forums
Forum List  »  German

Re: Produktdatenbank mit Produkteigenschaften
Posted by: Simon Maier
Date: March 20, 2012 02:00AM

Hallo,

Habe noch eine Frage zu den selben Tabellen.

Hinzu kommt jetzt noch eine Weitere Tabelle die attnames_id zu einem Namen umwandelt

CREATE TABLE IF NOT EXISTS `attnames` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `cat_id` int(10) unsigned NOT NULL,
  `si` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `grund` varchar(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `is_float` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;

INSERT INTO `attnames` (`id`, `cat_id`, `si`, `grund`, `is_float`) VALUES
(1, 15, 'Volt', 'V', 1),
(2, 15, 'Ampere', 'A', 1),
(3, 0, 'Ohm', 'R', 1),
(4, 1, 'Farbtemperatur (CCT)', 'K', 1),
(5, 1, 'Strom Test', 'A', 1),
(6, 1, 'Strom Max', 'A', 1),
(7, 1, 'Öffnungswinkel', '°', 1);


Am Ende soll bei der Abfrage dieses Ergebnis zu sehen sein:
Zuerst soll hier also die parts_id und der text sichtbar sein, Dahinter Folgen dann alle Eigenschaften (attnames_id -> attnames.si)

mit Hilfe von att.attnames_id wird der zugehöhrige Name aus der attnames.si geholt.

+----------+-------------+------+----------+-----+
| parts_id | parts.text | Volt | Ampere | Ohm |
+----------+-------------+------+----------+-----+
| 1 | Bauteil | 1.2 | 4.8 | 10 |
+----------+-------------+------+----------+-----+

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.