DATABASE Query STATEMENT

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2009
Posts: 11
Reputation: newbie_here is an unknown quantity at this point 
Solved Threads: 0
newbie_here newbie_here is offline Offline
Newbie Poster

DATABASE Query STATEMENT

 
0
  #1
Feb 26th, 2009
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

  1. select name,position,age,salary
  2. FROM personalinformation, salarydetails
  3. WHERE personalinformation.id = salarydetails.id
  4. AND salarydetails.salary = 2500

PLease help. Thanks in advance
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: DATABASE Query STATEMENT

 
0
  #2
Feb 27th, 2009
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 8
Reputation: aqee_se is an unknown quantity at this point 
Solved Threads: 0
aqee_se aqee_se is offline Offline
Newbie Poster

Re: DATABASE Query STATEMENT

 
0
  #3
Feb 27th, 2009
whats the error you encountered? can you explain. than may be some good result generate for you from others
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 13
Reputation: tmani_85 is an unknown quantity at this point 
Solved Threads: 2
tmani_85 tmani_85 is offline Offline
Newbie Poster

Re: DATABASE Query STATEMENT

 
0
  #4
Feb 28th, 2009
You need to store the personalinformation.id in salarydetails table. after that you need to link the personalinformation.id ane the personalinformation.id stored in salarydetails table.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: DATABASE Query STATEMENT

 
0
  #5
Mar 1st, 2009
For sure, they got error: ambiguity error, maybe the two tables have some same columns name, I see the syntax is correct.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 11
Reputation: newbie_here is an unknown quantity at this point 
Solved Threads: 0
newbie_here newbie_here is offline Offline
Newbie Poster

Re: DATABASE Query STATEMENT

 
0
  #6
Mar 1st, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 11
Reputation: newbie_here is an unknown quantity at this point 
Solved Threads: 0
newbie_here newbie_here is offline Offline
Newbie Poster

Re: DATABASE Query STATEMENT

 
0
  #7
Mar 1st, 2009
  1. INSERT INTO newtable AS (select personalinformation.name,personalinformation.position,personalinformation.age,salarydetails.salary
  2. FROM personalinformation, salarydetails
  3. WHERE personalinformation.id = salarydetails.id
  4. 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
Last edited by newbie_here; Mar 1st, 2009 at 10:22 pm.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 11
Reputation: newbie_here is an unknown quantity at this point 
Solved Threads: 0
newbie_here newbie_here is offline Offline
Newbie Poster

Re: DATABASE Query STATEMENT

 
0
  #8
Mar 1st, 2009
  1. INSERT INTO newtable(name,position,age,salary) values AS (select personalinformation.name,personalinformation.position,personalinformation.age,salarydetails.salary
  2. FROM personalinformation, salarydetails
  3. WHERE personalinformation.id = salarydetails.id
  4. 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
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: DATABASE Query STATEMENT

 
0
  #9
Mar 1st, 2009
Give us your code, we can't work with prediction!
Last edited by Ramy Mahrous; Mar 2nd, 2009 at 12:06 am.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 11
Reputation: newbie_here is an unknown quantity at this point 
Solved Threads: 0
newbie_here newbie_here is offline Offline
Newbie Poster

Re: DATABASE Query STATEMENT

 
0
  #10
Mar 2nd, 2009
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)"
Last edited by newbie_here; Mar 2nd, 2009 at 1:55 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC