Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8777515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:17:41+00:00 2026-06-13T19:17:41+00:00

I have 2 tables with the same columns, i need to show them all

  • 0

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),
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:17:43+00:00Added an answer on June 13, 2026 at 7:17 pm

    In can try something like:

    select id,locator,name,price, tableName from 
    (
      select a.id as id, a.locator as locator, a.name as name, 
         a.price as price, a.ibutik as ibutik, 'closes' as tableName 
        from  clothes a
      union all
      select b.id,b.locator,b.name,b.price,b.ibutik,'items' from items b 
    ) foo
    where ibutik=0;
    

    Validated with sqlFiddle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 3 database tables, all of them have the same 5 columns. They
I have 3 tables. They have the same columns. I need to merge them
I have three mysql table from same database Db1. Three tables have following columns.
I have a load of tables all with the same 2 datetime columns (lastModDate,
I have two tables, A and B. Both have the exact same columns. I
I have two tables, each has two columns. Is there a way to get
I have two tables with the same columns, and I need to copy one
Possible Duplicate: How to fetch result from MySQL row with multiple same-name columns with
I have to tables with the same layout (same columns). There is one ID
I have 2 tables that are similar but not the same so a union

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.