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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:39:14+00:00 2026-05-25T12:39:14+00:00

I am trying to populate one table from another table with mysql. First table

  • 0

I am trying to populate one table from another table with mysql. First table is users and the second table is technicians .

Users contains : userID, surname, firstname, loginid, password, accesslevel .

Technicians contains : techID, tech_surname, tech_firstname, tech_loginid, tech_password, tech_accesslevel.

When I add a user, I want the technicians table to populate if accesslevel=tech and users.loginid is not equal to technicians.tech_loginid.

I have tried several things and the result is that either no record is added or all records in users where accesslevel=tech are added each time, giving me several duplicate records.

I tried this:

INSERT INTO technicians (techID, tech_surname, tech_firstname, tech_loginid, tech_passwrd, tech_accesslevel)
SELECT firstname, surname, loginid, accesslevel, passwrd, tech_loginid
FROM users, technicians
WHERE accesslevel='tech' AND 'loginid!=tech_loginid'

It doesn’t work and if I remove the AND statement from the WHERE clause it pushes all the records each time a new user is added with accesslevel=tech.

What am I doing wrong? I’ve searched for hours for an answer.

Cheers

  • 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-25T12:39:15+00:00Added an answer on May 25, 2026 at 12:39 pm

    I think you’re trying to insert those technicians that already do not exist in that table so a query would be something like this

    INSERT INTO technicians  (techID, tech_surname, tech_firstname, tech_loginid, tech_passwrd, tech_accesslevel) 
    SELECT loginid, surname, firstname, tech_loginid, passwrd, accesslevel 
    FROM users 
    LEFT OUTER JOIN technicians ON loginid = tech_loginid
    WHERE accesslevel='tech' and tech_loginid IS null
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to populate a date table which contains every date for the
I'm trying to bind an onChange event of one FilteringSelect to populate another FilteringSelect
I am trying to populate a list box from a customers table in SQL
I'm trying to populate a dropdown list in my web page from a mysql
I'm trying to populate a table with user information in a MS SQL database
I'm trying to populate a List of beans from a form: public class Foo
I am trying to populate a variable with an XML response from an ajax
I'm trying to populate a new column in a table with data residing in
I have a table of Users (tblUsers) which contains details of University staff. I
I'm trying to use a BULK INSERT statement to populate a large (17-million-row) table

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.