Navigation |
PHP AND MySQL - JOINSubmitted by sudeepg on Tue, 07/31/2007 - 11:05.
JOIN in SQL combines records from 2 tables in a database. Often we might need to extract daata from 2 or more tables and then we need Joins. It simply is an act of joining 2 or more tables in a single temporary table. Example: DepartmentTable
EmployeeTable
Assume we have 2 tables as mentioned above. And we need to list people in each department. We can do this using a simple Join as follows: "Select EmployeeTable.EmployeeName, DepartmentTable.DepartmentName from EmployeeTable, DepartmentTable where EmployeeTable.DepartmentId = DepartmentTable.DepartmentId"; This is a "simple join" that fetches results from 2 tables and display it. The result is:
The Code in PHP for the same would be :
|
Active forum topicsUser login |
Recent comments
12 weeks 6 days ago
26 weeks 2 days ago
41 weeks 6 days ago
41 weeks 6 days ago
43 weeks 22 hours ago
49 weeks 2 days ago
49 weeks 2 days ago
51 weeks 5 days ago
1 year 37 min ago
1 year 1 hour ago