| | |
DATABASE Query STATEMENT
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2009
Posts: 11
Reputation:
Solved Threads: 0
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
PLease help. Thanks in advance
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)
select name,position,age,salary FROM personalinformation, salarydetails WHERE personalinformation.id = salarydetails.id AND salarydetails.salary = 2500
PLease help. Thanks in advance
Use Join statement
http://www.sql-tutorial.net/SQL-JOIN.asp
http://www.sql-tutorial.net/SQL-JOIN.asp
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
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
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Feb 2009
Posts: 11
Reputation:
Solved Threads: 0
VB.NET Syntax (Toggle Plain Text)
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
Last edited by newbie_here; Mar 1st, 2009 at 10:22 pm.
•
•
Join Date: Feb 2009
Posts: 11
Reputation:
Solved Threads: 0
VB.NET Syntax (Toggle Plain Text)
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
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
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Feb 2009
Posts: 11
Reputation:
Solved Threads: 0
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.
![]() |
Similar Threads
- Database Connectivity in C (C)
- Help with Database Query... (MySQL)
- How to execute MS Access Query using JDBC? (Java)
- Python-mysql for checking table exist or not (Python)
- connecting and passing query in VB6 and CR (Visual Basic 4 / 5 / 6)
- Need Help -- Database connectivity in C (C)
- SQL statement to query user input?? (MS Access and FileMaker Pro)
- JDBC connection (Java)
Other Threads in the VB.NET Forum
- Previous Thread: Insert from DataGridView
- Next Thread: Create a Menu with Button + IE + VB.Net
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2008 access add application arithmetic array assignment basic binary box button buttons center click code combo combobox component connectionstring convert cpu data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel exists firewall folder image images isnumericfuntioncall login math memory mobile module ms msaccess mssqlbackend mysql navigate net opacity pan peertopeervideostreaming picturebox picturebox1 port print printpreview problemwithinstallation project record regex reports" reuse right-to-left save savedialog search serial sorting sqldatbase storedprocedure string temp textbox timer txttoxmlconverter updown useraccounts usercontol usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vbnet view vista visual visualbasic visualbasic.net visualstudio web wpf xml






