Search code examples
mysqljoininner-join

Get column names of all the fields of a join Query in MySql


This is my simple join query, first table has 5 different fields and second one has three different fields and the join query is providing me 8 fields:

SELECT * FROM admin_users au
INNER JOIN admin_user_data aud
WHERE au.id = aud.admin_id

I want a MYSQL query that returns me all the eight field names and also its type.


Solution

  • I think You are looking for this...

    SELECT
        column_name,
        column_type    # or data_type 
    FROM information_schema.columns 
    WHERE table_name in('admin_users' ,'admin_user_data');