943,867 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 1452
  • VB.NET RSS
You are currently viewing page 1 of this multi-page discussion thread
Feb 26th, 2009
0

DATABASE Query STATEMENT

Expand Post »
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

VB.NET Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
newbie_here is offline Offline
11 posts
since Feb 2009
Feb 27th, 2009
0

Re: DATABASE Query STATEMENT

Reputation Points: 1182
Solved Threads: 392
Posting Sensei
Jx_Man is offline Offline
3,140 posts
since Nov 2007
Feb 27th, 2009
0

Re: DATABASE Query STATEMENT

whats the error you encountered? can you explain. than may be some good result generate for you from others
Reputation Points: 10
Solved Threads: 0
Newbie Poster
aqee_se is offline Offline
8 posts
since Dec 2008
Feb 28th, 2009
0

Re: DATABASE Query STATEMENT

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.
Reputation Points: 10
Solved Threads: 2
Newbie Poster
tmani_85 is offline Offline
14 posts
since Feb 2009
Mar 1st, 2009
0

Re: DATABASE Query STATEMENT

For sure, they got error: ambiguity error, maybe the two tables have some same columns name, I see the syntax is correct.
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Mar 1st, 2009
0

Re: DATABASE Query STATEMENT

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
newbie_here is offline Offline
11 posts
since Feb 2009
Mar 1st, 2009
0

Re: DATABASE Query STATEMENT

VB.NET Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
newbie_here is offline Offline
11 posts
since Feb 2009
Mar 1st, 2009
0

Re: DATABASE Query STATEMENT

VB.NET Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
newbie_here is offline Offline
11 posts
since Feb 2009
Mar 1st, 2009
0

Re: DATABASE Query STATEMENT

Give us your code, we can't work with prediction!
Last edited by Ramy Mahrous; Mar 2nd, 2009 at 12:06 am.
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Mar 2nd, 2009
0

Re: DATABASE Query STATEMENT

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

Quote ...
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
newbie_here is offline Offline
11 posts
since Feb 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Insert from DataGridView
Next Thread in VB.NET Forum Timeline: Create a Menu with Button + IE + VB.Net





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC