hi all
i am a newbie want to know how to get values from two tables in database. I hae two tables one is the personla information and the other table is the salary table .Both tables have id number which may join them to gather. But what i need to do is, i need to retrieve only people who have a salary of 2500. Is it possible. i have tried below but it does not work can tell me where i went wrong

select name,position,age,salary
FROM personalinformation, salarydetails
WHERE personalinformation.id = salarydetails.id
AND salarydetails.salary = 2500

PLease help. Thanks in advance

whats the error you encountered? can you explain. than may be some good result generate for you from others

For sure, they got error: ambiguity error, maybe the two tables have some same columns name, I see the syntax is correct.

Thanks all it worked...so my next step is that i need to save it in a new database table i created in the same database (access).... is it possible?

thanks a lot in advance

cheers
newbie

INSERT INTO newtable AS (select personalinformation.name,personalinformation.position,personalinformation.age,salarydetails.salary
FROM personalinformation, salarydetails
WHERE personalinformation.id = salarydetails.id
AND salarydetails.salary = 2500)

but the porblem i encounter is that it says that INSERT INTO syntax error. Can anyone help please

thanks in advance

cheers
newbie

INSERT INTO newtable(name,position,age,salary) values AS (select personalinformation.name,personalinformation.position,personalinformation.age,salarydetails.salary
FROM personalinformation, salarydetails
WHERE personalinformation.id = salarydetails.id
AND salarydetails.salary = 2500)

but the porblem i encounter is that it says that INSERT INTO syntax error. Can anyone help please

thanks in advance

cheers
newbie

i have pasted the code above already bro.....Because i need to save the values in a different table within the database. so i have a table called details. so i need to put all these generated values from the two tables into this table. when i tried compiling i get this error. invalid syntax.......attached down is my query string to place the values in another table. ihope this info issufficient ..... please help

Dim myQuery as String = " INSERT INTO details(name,position,age,salary) values AS (select personalinformation.name,personalinformation.position,personalinformation.age,salarydetails.salary
FROM personalinformation, salarydetails
WHERE personalinformation.id = salarydetails.id
AND salarydetails.salary = 2500)"

If you run it against SQL Server or MS Access take this statement and run it there, see if there's error or not.

This article has been dead for over six months. Start a new discussion instead.