Joins can be done even without writing the JOIN Keyword but using WHERE clause!
π This gives the same result as an INNER JOIN.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Old-Style WHERE Join vs INNER JOIN</title>
<style>
.infographic-oldjoinrunner {
--ink: #1a1a1a;
--ink-soft: #5c5c5c;
--paper: #ffffff;
--paper-alt: #f0ece4;
--accent: #2563eb;
--accent-soft:#e3ebfd;
--line: #ddd6c9;
--good: #16a34a;
--good-soft: #dcfce7;
--on-accent: #ffffff;
--display-font: Georgia, 'Iowan Old Style', serif;
--body-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
--mono-font: 'SF Mono', Consolas, monospace;
background: var(--paper);
color: var(--ink);
font-family: var(--body-font);
max-width: 780px;
margin: 0 auto;
box-sizing: border-box;
overflow-x: hidden;
}
.infographic-oldjoinrunner[data-theme="dark"] {
--ink: #e8e6e1;
--ink-soft: #9a968c;
--paper: #121212;
--paper-alt: #1e1e26;
--accent: #5b8def;
--accent-soft:#202942;
--line: #2c313d;
--good: #4ade80;
--good-soft: #123420;
--on-accent: #101418;
}
.infographic-oldjoinrunner * { box-sizing: border-box; }
.oj-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; gap: 0.5rem; flex-wrap: wrap; }
.oj-progress { font-size: 0.78rem; color: var(--ink-soft); }
.oj-showfull-btn {
font: inherit; font-size: 0.78rem; background: none; border: 1px solid var(--line);
border-radius: 999px; padding: 0.35rem 0.8rem; cursor: pointer; color: var(--ink-soft);
}
.oj-showfull-btn:hover { border-color: var(--accent); color: var(--accent); }
.oj-showfull-btn.is-on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.oj-fullcode-panel { display: none; margin-bottom: 1.25rem; }
.oj-fullcode-panel.is-visible { display: block; }
.oj-fullcode-scroll { overflow-x: auto; }
.oj-fullcode {
background: var(--ink); color: #d4e2ff; border-radius: 8px; padding: 1rem 1.2rem;
font-family: var(--mono-font); font-size: 0.72rem; line-height: 1.7; white-space: pre; opacity: 0.85;
display: inline-block;
min-width: 100%;
}
.infographic-oldjoinrunner[data-theme="dark"] .oj-fullcode { background: #05070a; }
.oj-frame { background: var(--paper-alt); border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem; }
.oj-kw { color: #9cc5ff; } .oj-str { color: #f8d980; } .oj-num { color: #4ade80; } .oj-cm { color: #7c8aa8; }
.oj-source-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); margin: 0 0 0.6rem; }
.oj-table-name { font-size: 0.7rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; margin: 0.4rem 0 0.2rem; }
.oj-mini-table-scroll { overflow-x: auto; margin-bottom: 0.6rem; }
table.oj-mini-table {
width: 100%; min-width: 200px; border-collapse: collapse; background: var(--paper);
border-radius: 7px; font-size: 0.8rem;
}
table.oj-mini-table th, table.oj-mini-table td {
border: 1px solid var(--line); padding: 0.4rem 0.55rem; text-align: left; white-space: nowrap;
}
table.oj-mini-table th { background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 0.68rem; }
table.oj-mini-table tr.is-new td { animation: oj-row-in 0.6s ease; }
@keyframes oj-row-in { from { background: var(--good-soft); } to { background: transparent; } }
.oj-step { display: none; margin-bottom: 1rem; }
.oj-step.is-revealed { display: block; animation: oj-step-in 0.4s ease; }
@keyframes oj-step-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.oj-step.is-done .oj-step-code-full { display: none; }
.oj-step.is-done .oj-step-done-pill { display: flex; }
.oj-step-done-pill {
display: none; align-items: center; gap: 0.5rem; background: var(--good-soft); color: var(--good);
border-radius: 7px; padding: 0.55rem 0.85rem; font-family: var(--mono-font); font-size: 0.78rem; cursor: pointer;
}
.oj-step-done-pill .chevron { margin-left: auto; font-size: 0.7rem; opacity: 0.7; }
.oj-step.is-expanded-done .oj-step-code-full { display: block; }
.oj-step.is-expanded-done .oj-step-done-pill { background: var(--accent-soft); color: var(--accent); }
.oj-step-label { font-family: var(--display-font); font-size: 1.02rem; margin: 0 0 0.5rem; }
.oj-step-desc { font-size: 0.82rem; color: var(--ink-soft); margin: 0 0 0.7rem; line-height: 1.45; }
.oj-code-scroll { overflow-x: auto; }
.oj-code {
background: var(--ink); color: #d4e2ff; border-radius: 8px; padding: 0.8rem 1rem;
font-family: var(--mono-font); font-size: 0.78rem; line-height: 1.6; white-space: pre;
display: inline-block;
min-width: 100%;
}
.infographic-oldjoinrunner[data-theme="dark"] .oj-code { background: #05070a; }
.oj-run-row { display: flex; justify-content: center; margin-top: 0.85rem; }
.oj-run-btn {
font: inherit; font-size: 0.85rem; background: var(--accent); color: var(--on-accent);
border: none; border-radius: 7px; padding: 0.55rem 1.1rem; cursor: pointer;
}
.oj-run-btn:hover { opacity: 0.9; }
.oj-run-btn:disabled { opacity: 0.55; cursor: wait; }
.oj-run-btn.is-secondary { background: var(--paper); color: var(--ink); border: 1px solid var(--line); }
.oj-output-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); margin: 1.1rem 0 0.6rem; }
.oj-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; min-width: 0; }
table.oj-table {
width: 100%; min-width: 220px; border-collapse: collapse; background: var(--paper);
border-radius: 8px; font-size: 0.88rem;
}
table.oj-table th, table.oj-table td {
border: 1px solid var(--line); padding: 0.5rem 0.7rem; text-align: left; white-space: nowrap;
}
table.oj-table th { background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 0.75rem; }
table.oj-table tr.is-new td { animation: oj-row-in 0.6s ease; }
.oj-status {
text-align: center; font-size: 0.82rem; margin-top: 0.85rem; padding: 0.5rem 0.8rem;
border-radius: 7px; display: none; background: var(--good-soft); color: var(--good);
}
.oj-status.is-visible { display: block; animation: oj-step-in 0.3s ease; }
.oj-match-note {
text-align: center; font-size: 0.85rem; margin-top: 1rem; padding: 0.7rem 0.9rem;
border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: none;
}
.oj-match-note.is-visible { display: block; }
.oj-reset-row { display: flex; justify-content: center; margin-top: 1.25rem; }
@media (prefers-reduced-motion: reduce) {
.infographic-oldjoinrunner *, .infographic-oldjoinrunner *::before, .infographic-oldjoinrunner *::after {
transition-duration: 0.001ms !important; animation-duration: 0.001ms !important;
}
}
</style>
</head>
<body>
<div class="infographic-oldjoinrunner" id="oldjoinrunner">
<div class="oj-topbar">
<span class="oj-progress" id="ojProgress"></span>
<button class="oj-showfull-btn" id="ojShowFullBtn" type="button">ποΈ Show full SQL script</button>
</div>
<div class="oj-fullcode-panel" id="ojFullCodePanel">
<div class="oj-fullcode-scroll">
<div class="oj-fullcode" id="ojFullCodeContent"></div>
</div>
</div>
<div class="oj-frame">
<div id="ojSourceWrap" style="display:none;">
<p class="oj-source-label">Source Tables</p>
<p class="oj-table-name">students</p>
<div class="oj-mini-table-scroll"><table class="oj-mini-table" id="ojStudentsTable"><thead><tr><th>id</th><th>name</th></tr></thead><tbody></tbody></table></div>
<p class="oj-table-name">enrollments</p>
<div class="oj-mini-table-scroll"><table class="oj-mini-table" id="ojEnrollTable"><thead><tr><th>id</th><th>student_id</th><th>course</th></tr></thead><tbody></tbody></table></div>
</div>
<div id="ojSteps"></div>
<p class="oj-status" id="ojStatus"></p>
<p class="oj-output-label" id="ojOutputLabel" style="display:none;">Query Result</p>
<div class="oj-table-scroll" id="ojTableScroll" style="display:none;">
<table class="oj-table" id="ojTable"></table>
</div>
<p class="oj-match-note" id="ojMatchNote">βοΈ Same rows, same order β the old comma + WHERE style and INNER JOIN produce identical results. Sara is excluded from both, since she has no matching enrollment.</p>
<div class="oj-reset-row">
<button class="oj-run-btn is-secondary" id="ojReset" type="button">βΊ Reset</button>
</div>
</div>
</div>
<script>
(function () {
const wrapper = document.getElementById('oldjoinrunner');
const bodyAttr = document.body.getAttribute('data-darkmode');
let dark;
if (bodyAttr === 'true') {
dark = true;
} else if (bodyAttr === 'false') {
dark = false;
} else {
const match = document.cookie.match(/(?:^|;\s*)darkMode=([^;]+)/);
dark = match ? match[1] === 'true' : false;
}
if (dark) wrapper.setAttribute('data-theme', 'dark');
})();
(function () {
function kw(s) { return '<span class="oj-kw">' + s + '</span>'; }
function str(s) { return '<span class="oj-str">' + s + '</span>'; }
function num(s) { return '<span class="oj-num">' + s + '</span>'; }
function cm(s) { return '<span class="oj-cm">' + s + '</span>'; }
const students = [{ id: 1, name: 'Anya' }, { id: 2, name: 'Ravi' }, { id: 3, name: 'Sara' }];
const enrollments = [{ id: 1, student_id: 1, course: 'Math' }, { id: 2, student_id: 1, course: 'Science' }, { id: 3, student_id: 2, course: 'English' }];
const setupCode =
cm('-- 1. Create students table') + '\n' +
kw('CREATE TABLE') + ' students (\n id ' + kw('INT AUTO_INCREMENT PRIMARY KEY') + ',\n name ' + kw('VARCHAR') + '(50) ' + kw('NOT NULL') + '\n);\n\n' +
cm('-- 2. Create enrollments table') + '\n' +
kw('CREATE TABLE') + ' enrollments (\n id ' + kw('INT AUTO_INCREMENT PRIMARY KEY') + ',\n student_id ' + kw('INT') + ',\n course ' + kw('VARCHAR') + '(50),\n ' + kw('FOREIGN KEY') + ' (student_id) ' + kw('REFERENCES') + ' students(id)\n);\n\n' +
cm('-- 3. Insert data into students') + '\n' + kw('INSERT INTO') + ' students (name) ' + kw('VALUES') + '\n(' + str("'Anya'") + '),\n(' + str("'Ravi'") + '),\n(' + str("'Sara'") + ');\n\n' +
cm('-- 4. Insert data into enrollments') + '\n' + kw('INSERT INTO') + ' enrollments (student_id, course) ' + kw('VALUES') + '\n' +
'(' + num('1') + ', ' + str("'Math'") + '),\n(' + num('1') + ', ' + str("'Science'") + '),\n(' + num('2') + ', ' + str("'English'") + ');';
const whereJoinCode = cm('-- 5. Join using WHERE clause (old style)') + '\n' + kw('SELECT') + ' students.name, enrollments.course\n' + kw('FROM') + ' students, enrollments\n' + kw('WHERE') + ' students.id = enrollments.student_id;';
const innerJoinCode = cm('-- The modern equivalent') + '\n' + kw('SELECT') + ' students.name, enrollments.course\n' + kw('FROM') + ' students\n' + kw('INNER JOIN') + ' enrollments ' + kw('ON') + ' students.id = enrollments.student_id;';
function joinRows() {
return enrollments.map(e => {
const s = students.find(st => st.id === e.student_id);
return [s.name, e.course];
});
}
const steps = [
{ key: 'setup', title: 'βοΈ Base Setup', desc: 'One students table, one enrollments table, connected by a foreign key.', code: setupCode, type: 'setup' },
{ key: 'whereJoin', title: '5\ufe0f\u20e3 Old-Style WHERE Join', desc: 'A comma between two tables plus a WHERE clause β this is how joins were written before explicit JOIN syntax existed.', code: whereJoinCode, type: 'query' },
{ key: 'innerJoin', title: 'π Modern INNER JOIN (equivalent)', desc: 'The same logic, written the modern way β run it and compare.', code: innerJoinCode, type: 'query' }
];
const stepsContainer = document.getElementById('ojSteps');
const progress = document.getElementById('ojProgress');
const outputLabel = document.getElementById('ojOutputLabel');
const tableScroll = document.getElementById('ojTableScroll');
const table = document.getElementById('ojTable');
const status = document.getElementById('ojStatus');
const matchNote = document.getElementById('ojMatchNote');
const fullCodeContent = document.getElementById('ojFullCodeContent');
fullCodeContent.innerHTML = [setupCode, whereJoinCode, innerJoinCode].join('\n\n');
steps.forEach((s, i) => {
const stepEl = document.createElement('div');
stepEl.className = 'oj-step' + (i === 0 ? ' is-revealed' : '');
stepEl.id = 'step-' + s.key;
const label = s.type === 'setup' ? 'Setup' : ('Run ' + s.title.replace(/^[^\s]+\s?/, ''));
stepEl.innerHTML =
'<div class="oj-step-done-pill"><span>β ' + s.title + '</span><span class="chevron">\u25be view code</span></div>' +
'<div class="oj-step-code-full">' +
'<p class="oj-step-label">' + s.title + '</p>' +
'<p class="oj-step-desc">' + s.desc + '</p>' +
'<div class="oj-code-scroll"><div class="oj-code">' + s.code + '</div></div>' +
'<div class="oj-run-row"><button class="oj-run-btn" id="btn-' + s.key + '" type="button">βΆ ' + label + '</button></div>' +
'</div>';
stepsContainer.appendChild(stepEl);
});
function updateProgress(doneCount) {
progress.textContent = doneCount + ' / ' + steps.length + ' steps run';
}
updateProgress(0);
function showStatus(text) {
status.textContent = text;
status.classList.add('is-visible');
}
function renderResult(rows) {
let html = '<thead><tr><th>name</th><th>course</th></tr></thead><tbody>';
rows.forEach(r => { html += '<tr class="is-new"><td>' + r[0] + '</td><td>' + r[1] + '</td></tr>'; });
html += '</tbody>';
table.innerHTML = html;
outputLabel.style.display = 'block';
tableScroll.style.display = 'block';
}
let doneCount = 0;
document.getElementById('btn-setup').addEventListener('click', () => {
document.getElementById('btn-setup').disabled = true;
status.classList.remove('is-visible');
setTimeout(() => {
document.getElementById('ojSourceWrap').style.display = 'block';
document.querySelector('#ojStudentsTable tbody').innerHTML = students.map(s => '<tr class="is-new"><td>' + s.id + '</td><td>' + s.name + '</td></tr>').join('');
document.querySelector('#ojEnrollTable tbody').innerHTML = enrollments.map(e => '<tr class="is-new"><td>' + e.id + '</td><td>' + e.student_id + '</td><td>' + e.course + '</td></tr>').join('');
showStatus('βοΈ Both tables created, all sample data inserted.');
finish('setup');
}, 350);
});
['whereJoin', 'innerJoin'].forEach(key => {
document.getElementById('btn-' + key).addEventListener('click', () => {
document.getElementById('btn-' + key).disabled = true;
status.classList.remove('is-visible');
matchNote.classList.remove('is-visible');
setTimeout(() => {
const rows = joinRows();
renderResult(rows);
showStatus('βοΈ ' + rows.length + ' rows returned.');
if (key === 'innerJoin') {
matchNote.classList.add('is-visible');
}
finish(key);
}, 350);
});
});
function finish(key) {
document.getElementById('step-' + key).classList.add('is-done');
doneCount++;
updateProgress(doneCount);
const idx = steps.findIndex(s => s.key === key);
const next = steps[idx + 1];
if (next) {
const nextEl = document.getElementById('step-' + next.key);
nextEl.classList.add('is-revealed');
nextEl.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
}
}
document.getElementById('ojShowFullBtn').addEventListener('click', function () {
const panel = document.getElementById('ojFullCodePanel');
const on = panel.classList.toggle('is-visible');
this.classList.toggle('is-on', on);
this.textContent = on ? 'ποΈ Hide full SQL script' : 'ποΈ Show full SQL script';
});
document.querySelectorAll('.oj-step-done-pill').forEach(pill => {
pill.addEventListener('click', () => {
const step = pill.closest('.oj-step');
step.classList.toggle('is-expanded-done');
pill.querySelector('.chevron').textContent = step.classList.contains('is-expanded-done') ? '\u25b4 hide code' : '\u25be view code';
});
});
document.getElementById('ojReset').addEventListener('click', () => {
doneCount = 0;
updateProgress(0);
status.classList.remove('is-visible');
outputLabel.style.display = 'none';
tableScroll.style.display = 'none';
matchNote.classList.remove('is-visible');
table.innerHTML = '';
document.getElementById('ojSourceWrap').style.display = 'none';
document.querySelector('#ojStudentsTable tbody').innerHTML = '';
document.querySelector('#ojEnrollTable tbody').innerHTML = '';
steps.forEach((s, i) => {
const el = document.getElementById('step-' + s.key);
el.classList.remove('is-done', 'is-expanded-done');
el.classList.toggle('is-revealed', i === 0);
document.getElementById('btn-' + s.key).disabled = false;
});
});
})();
</script>
</body>
</html>.demo {
font-family: system-ui, sans-serif;
padding: 16px;
}
.demo h1 {
color: #2563eb;
margin: 0 0 8px;
}
.demo p {
color: #4b5563;
margin: 0;
}document.querySelector('.demo h1')?.addEventListener('click', () => {
alert('Hello from live preview!');
});β οΈ Limitations
β You cannot use LEFT JOIN, RIGHT JOIN, or FULL OUTER JOIN with this syntax
β Only supports INNER JOIN
π§Ό Explicit JOIN syntax is more readable and maintainable
β Summary
Style | Syntax Example |
|---|---|
β Implicit JOIN |
|
β INNER JOIN |
|
β No LEFT/RIGHT | Implicit join canβt do outer joins |