• About Us
  • Privacy Policy
  • Disclaimer
  • Contact Us
AimactGrow
  • Home
  • Technology
  • AI
  • SEO
  • Coding
  • Gaming
  • Cybersecurity
  • Digital marketing
No Result
View All Result
  • Home
  • Technology
  • AI
  • SEO
  • Coding
  • Gaming
  • Cybersecurity
  • Digital marketing
No Result
View All Result
AimactGrow
No Result
View All Result

Avoiding SQL Ambiguities attributable to JOIN USING and NATURAL JOIN

Admin by Admin
May 4, 2026
Home Coding
Share on FacebookShare on Twitter


Some SQL operators are as esoteric as they’re highly effective. One of many oldest operator that you just’ve probably hardly utilized in actual world purposes is NATURAL JOIN which is the default in relational algebra. We’ve lined a cool use-case for NATURAL JOIN earlier on this weblog.

The principle motive why it’s not very helpful is as a result of it joins two tables utilizing all column names from each joined tables. In the event you have a look at the Sakila database, this contains audit columns like LAST_UPDATE, which is current on all tables. For instance, you wouldn’t need:

As a result of that might be equal to:

That is an apparent motive, however even when you fastidiously design your schema to by no means include two columns that “unintentionally” share their identify, somebody may add one accidentally, nonetheless, which renders present queries ineffective.

JOIN USING to the rescue?

So, you’d assume that the syntax that ought to actually be used as a substitute is JOIN .. USING? This seems to be good, doesn’t it?

And sure, that is actually cool for ad-hoc SQL. In case your schema is designed this fashion (major key column identify = international key column identify), then this syntax can be utilized to shortly be a part of tables throughout the schema.

However in an actual world software, it is best to nonetheless keep away from the syntax to stop disagreeable surprises when evolving the schema. Have a look at this script, for instance:

The question works completely effective as meant. However what occurs if we add:

Now, there’s an ambiguity within the final JOIN. If we repeat the SELECT assertion from earlier, PostgreSQL complains:

ERROR: widespread column identify “j” seems greater than as soon as in left desk

Oracle confirms:

SQL Error [918] [42000]: ORA-00918: J: column ambiguously specified – seems in A and B

Why? As a result of we’re actually becoming a member of:

And since j shouldn’t be a be a part of column between a and b, it’s now ambiguous. Be aware how the ALTER TABLE assertion broke a question that was completely effective earlier than. It might not have damaged if we used the JOIN .. ON syntax:

Too dangerous! Once more, when writing ad-hoc SQL for fast querying the Sakila database, JOIN .. USING is a great tool – similar to SELECT *. However in manufacturing queries, this ad-hoc SQL software ought to be prevented.

Like this:

Like Loading…

Tags: AmbiguitiesAvoidingcausedJOINNaturalSQL
Admin

Admin

Next Post
The way to do a web site content material audit in 2026 (with template)

The way to do a web site content material audit in 2026 (with template)

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended.

Baidu CEO Robin Li says demand for text-based fashions like DeepSeek’s is “shrinking” and claims its mannequin had the next propensity for “hallucinations” (Eleanor Olcott/Monetary Instances)

Meta strikes a 20-year deal to purchase 2,600+ MW of nuclear energy from Vistra, and broadcasts offers to again new reactor tasks from TerraPower and Oklo (Jennifer Hiller/Wall Avenue Journal)

January 9, 2026
Attorneys may face ‘extreme’ penalties for pretend AI-generated citations, UK courtroom warns

Attorneys may face ‘extreme’ penalties for pretend AI-generated citations, UK courtroom warns

June 8, 2025

Trending.

The way to Clear up the Wall Puzzle in The place Winds Meet

The way to Clear up the Wall Puzzle in The place Winds Meet

November 16, 2025
Researchers Uncover Crucial GitHub CVE-2026-3854 RCE Flaw Exploitable by way of Single Git Push

Researchers Uncover Crucial GitHub CVE-2026-3854 RCE Flaw Exploitable by way of Single Git Push

April 29, 2026
Google Introduces Simula: A Reasoning-First Framework for Producing Controllable, Scalable Artificial Datasets Throughout Specialised AI Domains

Google Introduces Simula: A Reasoning-First Framework for Producing Controllable, Scalable Artificial Datasets Throughout Specialised AI Domains

April 21, 2026
Google DeepMind Introduces Decoupled DiLoCo: An Asynchronous Coaching Structure Reaching 88% Goodput Below Excessive {Hardware} Failure Charges

Google DeepMind Introduces Decoupled DiLoCo: An Asynchronous Coaching Structure Reaching 88% Goodput Below Excessive {Hardware} Failure Charges

April 24, 2026
5 AI Compute Architectures Each Engineer Ought to Know: CPUs, GPUs, TPUs, NPUs, and LPUs In contrast

5 AI Compute Architectures Each Engineer Ought to Know: CPUs, GPUs, TPUs, NPUs, and LPUs In contrast

April 10, 2026

AimactGrow

Welcome to AimactGrow, your ultimate source for all things technology! Our mission is to provide insightful, up-to-date content on the latest advancements in technology, coding, gaming, digital marketing, SEO, cybersecurity, and artificial intelligence (AI).

Categories

  • AI
  • Coding
  • Cybersecurity
  • Digital marketing
  • Gaming
  • SEO
  • Technology

Recent News

10 Video games To Play If You Love Saros

10 Video games To Play If You Love Saros

May 4, 2026
AI-Powered Phishing, Android Spying Device, Linux Exploit, GitHub RCE & Extra

AI-Powered Phishing, Android Spying Device, Linux Exploit, GitHub RCE & Extra

May 4, 2026
  • About Us
  • Privacy Policy
  • Disclaimer
  • Contact Us

© 2025 https://blog.aimactgrow.com/ - All Rights Reserved

No Result
View All Result
  • Home
  • Technology
  • AI
  • SEO
  • Coding
  • Gaming
  • Cybersecurity
  • Digital marketing

© 2025 https://blog.aimactgrow.com/ - All Rights Reserved