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

  • Home
  • SEARCH
  • 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 4025784
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:53:23+00:00 2026-05-20T10:53:23+00:00

I am comparing database tables on a development server against a live server, looking

  • 0

I am comparing database tables on a development server against a live server, looking for column name changes, new columns, and columns that have been dropped. I’d like to do something like this:

SELECT GROUP_CONCAT(Field) FROM (SHOW COLUMNS ON table_name) GROUP BY Field

What I am after is a comma-delimited list that I can then take to the live server and do:

SHOW COLUMNS FROM table_name WHERE NOT IN ([comma-delimited list from above query])

Any thoughts on how best to do this – either by correcting me in my own approach, or by another means all together? Obviously, the above SQL does not work.

A note: The servers are entirely separate and may not communicate with each other, so no direct comparison is possible.


EDIT

Thanks for the answers, guys! Applying your answers to the question, this is my final SQL to get the column names:

SELECT CONCAT("'", GROUP_CONCAT(column_name ORDER BY ordinal_position SEPARATOR "', '"), "'") AS columns
FROM information_schema.columns
WHERE table_schema = 'db_name' AND table_name = 'tbl_name'

That gives me a list that looks like this:

'id', 'name', 'field1', 'field2'

Then I can use this query to compare:

SELECT GROUP_CONCAT(column_name ORDER BY ordinal_position)
FROM information_schema.columns
WHERE table_schema = 'db_name' AND table_name = 'tbl_name' AND column_name NOT IN ('id', 'name', 'field1', 'field2')

The results are a list of any columns that exist in the first database and not in the second. Perfect!

  • 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-05-20T10:53:23+00:00Added an answer on May 20, 2026 at 10:53 am

    Take a look at the information_schema.columns table

    select group_concat(column_name order by ordinal_position)
    from information_schema.columns
    where table_schema = 'database_name' and table_name = 'table_name'
    

    edit. Information schema allows you to make queries on metadata.
    So, you can even compare fields between tables with a left join for example.

    edit. Hi Chris. Glad you’ve solved. As you said your problem was quite different because it concerned with different servers. I add an example of two different databases on the same server.

    create database db1;
    use db1;
    create table table1(
    id int not null auto_increment primary key,
    name varchar(50),
    surname varchar(50),
    dob date)
    engine = myisam;
    
    create database db2;
    create table db2.table2 like db1.table1;
    alter table db2.table2 drop column dob;
    
    select i1.column_name from (
    select column_name
    from information_schema.columns 
    where table_schema = 'db1' and table_name = 'table1' ) as i1
    left join (
    select column_name
    from information_schema.columns 
    where table_schema = 'db2' and table_name = 'table2' ) as i2
    on i1.column_name = i2.column_name
    where i2.column_name is null
    

    and the obvious result is dob that is present in table1 and not in table2.

    Hope that it helps someone else. Regards guys. 🙂

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

Sidebar

Related Questions

I'm working on a home project that involves comparing images to a database of
I have trouble comparing 2 double in Excel VBA suppose that I have the
I am comparing queries my development and production database. They are both Oracle 9i,
I'm comparing between two techniques to create partitioned tables in SQL 2005. Use partitioned
I wrote a small app that allows me to compare two database schemas to
Our program ships with an SQL Server 2005 database and SQL Server 2005 Express.
I am trying to compare two tables to find rows in each table that
Do T-SQL queries in SQL Server support short-circuiting? For instance, I have a situation
Comparing string in C# is pretty simple. In fact there are several ways to
Comparing LinkedLists and Arrays while also comparing their differences with sorted and unsorted data

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.