fastix®: Alle Ergebnisse aus JOIN holen

Beitrag lesen

Moin!

CREATE TABLE IF NOT EXISTS `produkte` (  
  `id` int(11) NOT NULL auto_increment,  
  `name` text NOT NULL,  
  PRIMARY KEY  (`id`)  
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5;
INSERT INTO `produkte` (`id`, `name`) VALUES  
(0, 'ipad'),  
(1, 'iphone'),  
(2, 'ipod touch'),  
(3, 'blackberry');
CREATE TABLE IF NOT EXISTS `angebote` (  
  `id` int(11) NOT NULL auto_increment,  
  `angebotname` text NOT NULL,  
  `produktid` int(11) NOT NULL,  
  PRIMARY KEY  (`id`)  
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
  
INSERT INTO `angebote` (`id`, `angebotname`, `produktid`) VALUES  
(0, 'ipad4free', 1),  
(1, 'iphone4free', 2),  
(2, 'blackberryNOT4free', 3);
SELECT  
  `produkte`.`id`           AS `p_id`,  
  `produkte`.`name`         AS `p_name`,  
  `angebote`.`id`           AS `a_id`,  
  `angebote`.`produktid`    AS `a_p_id`,  
  `angebote`.`angebotname`  AS `a_name`  
FROM  
  `produkte`,  
  `angebote`  
WHERE  
  `produkte`.`name` LIKE '%IP%'  
AND  
  `angebote`.`produktid`=`produkte`.`id`;

Sowas?

MFFG (Mit freundlich- friedfertigem Grinsen)

fastix