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 6983895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:28:44+00:00 2026-05-27T18:28:44+00:00

I am creating a new table in a database called ‘production’ by joining data

  • 0

I am creating a new table in a database called ‘production’ by joining data from two tables in another database called ‘crawler’. I create this new table with the following SQL query ( this query works perfectly ):

CREATE TABLE files_and_metas_joined
SELECT
    crawler.files.id,
    crawler.files.company_id,
    crawler.file_metas.title,
    crawler.file_metas.h1_tags
FROM
    crawler.files,
    crawler.file_metas
WHERE
    crawler.files.id = crawler.file_metas.file_id
    AND
    crawler.files.processed = 1
    AND
    crawler.files.junk = 0

I’d like to also add the following indexes to this table but can’t seem to figure out how to do it in the same SQL query.

PRIMARY KEY (`id`),
KEY `company_id` (`company_id`),
KEY `title` (`title`),
KEY `h1_tags` (`h1_tags`)

Can this be done in the same query used to create the table? If not, how do I add these indexes with a query afterwards?

  • 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-27T18:28:44+00:00Added an answer on May 27, 2026 at 6:28 pm

    You can do it in the same statement, they just have to go before the SELECT:

    CREATE TABLE files_and_metas_joined
    (
      PRIMARY KEY (`id`),
      KEY `company_id` (`company_id`),
      KEY `title` (`title`),
      KEY `h1_tags` (`h1_tags`)
    )
    SELECT
        crawler.files.id,
        crawler.files.company_id,
        crawler.file_metas.title,
        crawler.file_metas.h1_tags
    FROM
        crawler.files,
        crawler.file_metas
    WHERE
        crawler.files.id = crawler.file_metas.file_id
        AND
        crawler.files.processed = 1
        AND
        crawler.files.junk = 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a new database to manage wish lists. Solution A: Two tables,
I need UNION two tables with creating new field, where 1 for first table,
When I am creating a new database table, what factors should I take into
When creating a new table in a database, what is the importance of using
I'm grabbing field row from one table and creating a new table for each
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
Can I avoid third party code from creating new threads, starting new VMs, or
I need to restrict the development users from creating new schedules for SQL Agent
I need to create a field in a database table, already populated with data.
I'm fairly new to database design, but I understand the fundamentals. I'm creating a

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.