I have 2 tables with the same columns, i need to show them all from both tables, but now i get all columns in each row, ex. locator 2 times per row, it has to show only 1, from the correct table.
SELECT a.*, b.* FROM clothes a, items b group by a.locator,b.locator
How do i do this?
I will have it outputs from both tables with rows. “name”,”locator”,”price” and WHERE “ibutik” = 1.
Clothes table with test rows:
CREATE TABLE IF NOT EXISTS `clothes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`locator` varchar(48) DEFAULT NULL,
`name` varchar(32) DEFAULT NULL,
`price` int(11) DEFAULT '100',
`level` smallint(6) DEFAULT '0',
`type` smallint(6) DEFAULT NULL,
`sex` smallint(4) DEFAULT NULL,
`x_offset` smallint(6) DEFAULT '0',
`y_offset` smallint(6) DEFAULT '0',
`nontradeable` tinyint(4) DEFAULT '0',
`ibutik` int(1) NOT NULL,
`koebt` int(9) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=55 ;
INSERT INTO `clothes` (`id`, `locator`, `name`, `price`, `level`, `type`, `sex`, `x_offset`, `y_offset`, `nontradeable`, `ibutik`, `koebt`) VALUES
(1, '1.png', 'Male body', 100, 1, 2, 1, 0, 0, 0, 0, 0),
(3, '1.png', 'Female body\r\n', 100, 1, 1, 2, 0, 0, 0, 0, 0))
And items:
CREATE TABLE IF NOT EXISTS `items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`locator` varchar(32) DEFAULT '',
`name` varchar(32) DEFAULT '',
`price` int(11) DEFAULT '100',
`level` smallint(6) DEFAULT '0',
`rotateable` tinyint(4) DEFAULT '0',
`x_offset` smallint(6) DEFAULT '0',
`y_offset` smallint(6) DEFAULT '0',
`z_index` smallint(6) DEFAULT '0',
`nontradeable` tinyint(4) DEFAULT '0',
`ibutik` int(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=20 ;
INSERT INTO `items` (`id`, `locator`, `name`, `price`, `level`, `rotateable`, `x_offset`, `y_offset`, `z_index`, `nontradeable`, `ibutik`) VALUES
(1, 'rodplante.png', 'Rød plante', 10, 0, 0, 0, 0, 0, 0, 1),
(2, '1.png', 'Gul plante', 0, 0, 0, 0, 0, 0, 0, 0),
(3, '2.png', 'Gul plante', 0, 0, 0, 0, 0, 0, 0, 0),
In can try something like:
Validated with sqlFiddle.