zhenguoli
zhenguoli

Reputation: 2308

Mysql: how can `natural join` using `join_condition`?

In Mysql, I found the natural join syntax is:

`table_reference NATURAL [{LEFT|RIGHT} [OUTER]] JOIN table_factor`,  

but other join types like inner or outer join can use join_conditon, like the syntax:

`table_reference {LEFT|RIGHT} [OUTER] JOIN table_reference join_condition`,   

so how can I use join_condition in natural join? Is there some alternatives?

Upvotes: 1

Views: 478

Answers (1)

tpdi
tpdi

Reputation: 35171

A natural join has an implicit join condition, equality on all columns with the same name.

If you want some other join condition, don't use a natural join. If a natural join's implicit join condition is what you want, use that. In general, it's probably easier for everyone to understand if you don't use a natural join and make your join condition explicit.

Upvotes: 3

Related Questions