Query does not return all of the expected results

jiblankman

Registered User.
Local time
Today, 13:20
Joined
May 27, 2008
Messages
43
I have two tables that are the called "Clients" and "Employees". These tables are the result of merging similar tables from three other databases.

The client table has a single entry for each clientid but the employee table can have multiple employees for each clientid. I need to create a table containing all employees from the Employees table who work for a client that has a randompool code of 6. This is the SQL that I am using.

INSERT INTO [Pool] SELECT [Employees].clientid, [Employees].employeeid, [Employees].ename FROM [Employees] INNER JOIN [Clients] ON [Employees].clientid = [Clients].clientid WHERE [Clients].randompool = '6';"

There should be 65 employees in the resulting table, but only 1 appears. Any help would be great, thanks.
 
Without seeing your Table/Data structure it is going to be very difficult to give any sort of sensible advise. Could you possibly post a copy of your DB to help us out.
 
Unfortunately I cannot post the DB due to confidential information, but here are the table structures:

Clients:
clientid - TEXT PRIMARY KEY
clientname - TEXT
clientAddress - TEXT
clientCity - TEXT
clientState - TEXT
clientZIP - TEXT
randompool - TEXT

Employees:
employeeid - TEXT
ename - TEXT
clientid - TEXT PRIMARY KEY

Please let me know what other information you need and thanks.
 
Last edited:
Never mind. I realized that the Primary Key on the Employees table was on the wrong column, it should have been the employeeid column. Now all is good.
 

Users who are viewing this thread

Back
Top Bottom