![]() |
conditional join
I am having the hardest time trying to figure out how to join tables if data is not present. The field "draftman" is sometimes known and sometimes NULL. I don't have a problem when a value is present, but how can I join the tables JobInfo and Employees when the draftsman value is NULL?
The line Code:
inner join Employees as dm on JobInfo.draftsman = dm.empIDBelow is my code: Code:
$result= mysql_query (" |
Re: conditional join
Use LEFT JOIN on the table where data may or may not be present.
|
Re: conditional join
Pefect. Still trying to figure out how these tables join together. Thanks for the solution.
|
Re: conditional join
Guess that's why I couldn't find any results when searching for "conditional join". :)
|
Re: conditional join
Code: SQL
|
Re: conditional join
Alternatively, You can use Conditional Left Joins.
It is simple. You can see comprehensive post on MySQL conditional Joins at mysqldiary.com/conditional-joins-in-mysql |
| All times are GMT +5.5. The time now is 20:02. |