Home » questions » JOIN statement?

JOIN statement?

2006-08-01 01:19:53, Category: Programming & Design
for SQL query...i want to get the user name and password from the UserPassword table....how do i use the join statement.. is it something like SELECT username, password FROM UserPassword WHERE username.UserPassword JOIN password.UserPassword And username ='"&txtUserName.text&"'"

Answers

  1. publicguest

    On 2006-08-01 02:42:05


    i know one thing clearly, username and passoword comes as a one column ---------------you expect like this if you expect like this use the below query SELECT username||' '||password FROM UserPassword WHERE username ='"&txtUserName.text&"'" generally JOIN are used in select statment for combining more than one table. Differenct type of JOIN's are there (1)OUTER join (2)INNER join
  2. sj

    On 2006-08-01 01:33:51


    A JOIN statement is used to "join" data from two tables. It is not required when you need data only from one table. Do you have 1 table or 2 ? An example of a join is Assume tables employee (empno, ename, salary, dt of joining,deptno) department(deptno, deptname) SELECT ename, deptname FROM employee, department WHERE employee.deptno = department.deptno SELECT ename, deptname FROM employee INNER JOIN department ON (employee.deptno,department.deptno) The query you want is SELECT username, password FROM UserPassword WHERE username="&txtUserName.text&"
  3. Indian_Male

    On 2006-08-01 01:32:25


    Join is used to bring data from other tables than the base table (the main table used in query). For ex: you have a table Employees with Emp_Id, Name, Job_Title columns. Other table is UserPWD with Emp_Id, User_Name, Password columns. Now you want to display Name, Job_Title, User_Name and Password for each user. Your SELECT stmt would be: Select Name, Job_Title, User_Name, Password from Employees, UserPWD where Employees.Emp_Id = UserPWD.Emp_Id; In essence: Include required columns from required tables. If the column is in more that one table, use table.column for clarity. In WHERE Clause, you use the join to specify the relationship. Syntax: Select a.col, b.col from table1 a, table2 b where a.col = b.col You can use aliases for tablenames like shown above. From your description, it looks like you are using only one table. Then you dont need a join.
  4. haroldminer

    On 2006-08-01 01:34:41


    Agree with Indian_Male! See: http://www.w3schools.com/sql/sql_join.asp