Skip to content

Commit b5ae520

Browse files
committed
Syntax fix to highlight SQL on SQL vs. TypeQL page
1 parent 67169fb commit b5ae520

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

core-concepts/modules/ROOT/pages/typeql/sql-vs-typeql.adoc

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Each `person` has a name, email, and age. Each `company` has a name. The `employ
1919

2020
Example SQL table definitions:
2121

22-
[sql]
22+
[,sql]
2323
----
2424
CREATE TABLE person (
2525
id SERIAL PRIMARY KEY,
@@ -73,7 +73,7 @@ insert
7373
In SQL, `SELECT` retrieves data from tables. In TypeQL, `match` finds data by pattern, and `fetch` or `select` projects the results.
7474

7575
**SQL:**
76-
[sql]
76+
[,sql]
7777
----
7878
SELECT name, email FROM person;
7979
----
@@ -108,7 +108,7 @@ fetch {
108108
SQL's `WHERE` clause filters rows. In TypeQL, constraints are part of the `match` pattern.
109109

110110
**SQL:**
111-
[sql]
111+
[,sql]
112112
----
113113
SELECT name FROM person WHERE age > 25;
114114
----
@@ -140,7 +140,7 @@ SQL uses `AND` (conjunction) and `OR` (disjunction) in `WHERE` clauses.
140140
In TypeQL, statements and composite patterns are combined an implicit `and` by default: `;` and `,` both are implicit conjunctions. An `or` pattern is used to explicitly represent a disjunction.
141141

142142
**SQL with AND:**
143-
[sql]
143+
[,sql]
144144
----
145145
SELECT name FROM person WHERE age > 25 AND email LIKE '%@example.com';
146146
----
@@ -157,7 +157,7 @@ select $name;
157157
----
158158

159159
**SQL with OR:**
160-
[sql]
160+
[,sql]
161161
----
162162
SELECT name FROM person WHERE age < 20 OR age > 30;
163163
----
@@ -182,7 +182,7 @@ The type of JOIN determines which entities are included in the results when rela
182182
An INNER JOIN returns only rows where there is a match in both tables. In TypeQL, this is the default behavior when matching relations.
183183

184184
**SQL:**
185-
[sql]
185+
[,sql]
186186
----
187187
SELECT p.name, e.id
188188
FROM person p
@@ -207,7 +207,7 @@ A LEFT JOIN returns all rows from the left table (person), and matching rows fro
207207
If there's no match, NULL values are returned for the right table columns. In TypeQL, use the `try` construct for optional matching.
208208

209209
**SQL:**
210-
[sql]
210+
[,sql]
211211
----
212212
SELECT p.name, e.id
213213
FROM person p
@@ -235,7 +235,7 @@ A RIGHT JOIN returns all rows from the right table (employment), and matching ro
235235
If there's no match, NULL values are returned for the left table columns. In TypeQL, reverse the pattern to start from the right side.
236236

237237
**SQL:**
238-
[sql]
238+
[,sql]
239239
----
240240
SELECT p.name, e.id
241241
FROM person p
@@ -264,7 +264,7 @@ A CROSS JOIN returns the Cartesian product of two tables - every row from the fi
264264
In TypeQL, match entities from both types independently without requiring any relation between them.
265265

266266
**SQL:**
267-
[sql]
267+
[,sql]
268268
----
269269
SELECT p.name, e.id
270270
FROM person p
@@ -294,7 +294,7 @@ Full outer joins do not translate well to TypeQL. If your application requires a
294294
=== INSERT → insert
295295

296296
**SQL:**
297-
[sql]
297+
[,sql]
298298
----
299299
INSERT INTO person (name, email, age) VALUES ('David', 'david@example.com', 28);
300300
----
@@ -308,7 +308,7 @@ insert
308308
----
309309

310310
**SQL INSERT with SELECT:**
311-
[sql]
311+
[,sql]
312312
----
313313
INSERT INTO employment (employee_id, employer_id)
314314
SELECT p.id, c.id
@@ -330,7 +330,7 @@ insert
330330
=== UPDATE → update
331331

332332
**SQL:**
333-
[sql]
333+
[,sql]
334334
----
335335
UPDATE person SET email = 'newemail@example.com' WHERE name = 'Alice';
336336
----
@@ -353,7 +353,7 @@ It automatically deletes the old value and inserts the new one.
353353
=== DELETE → delete
354354

355355
**SQL:**
356-
[sql]
356+
[,sql]
357357
----
358358
DELETE FROM person WHERE name = 'Charlie';
359359
----
@@ -368,7 +368,7 @@ delete $p;
368368
----
369369

370370
**SQL DELETE with JOIN:**
371-
[sql]
371+
[,sql]
372372
----
373373
DELETE e FROM employment e
374374
INNER JOIN person p ON e.employee_id = p.id
@@ -390,7 +390,7 @@ delete $e;
390390
=== GROUP BY → reduce with groupby
391391

392392
**SQL:**
393-
[sql]
393+
[,sql]
394394
----
395395
SELECT age, COUNT(*) as count
396396
FROM person
@@ -409,7 +409,7 @@ reduce $count = count groupby $age;
409409
=== Aggregate Functions
410410

411411
**SQL:**
412-
[sql]
412+
[,sql]
413413
----
414414
SELECT
415415
COUNT(*) as total,
@@ -437,7 +437,7 @@ reduce
437437
=== HAVING → reduce + match
438438

439439
**SQL:**
440-
[sql]
440+
[,sql]
441441
----
442442
SELECT age, COUNT(*) as count
443443
FROM person
@@ -460,7 +460,7 @@ match $count > 1;
460460
=== ORDER BY → sort
461461

462462
**SQL:**
463-
[sql]
463+
[,sql]
464464
----
465465
SELECT name, age FROM person ORDER BY age DESC, name ASC;
466466
----
@@ -478,7 +478,7 @@ select $name, $age;
478478
=== LIMIT and OFFSET
479479

480480
**SQL:**
481-
[sql]
481+
[,sql]
482482
----
483483
SELECT name FROM person ORDER BY name LIMIT 10 OFFSET 20;
484484
----
@@ -507,7 +507,7 @@ If we did `limit`, then `order`, we would `limit` the sorted answers to the firs
507507
=== DISTINCT → distinct
508508

509509
**SQL:**
510-
[sql]
510+
[,sql]
511511
----
512512
SELECT DISTINCT age FROM person;
513513
----
@@ -525,7 +525,7 @@ distinct;
525525
=== Subqueries → functions
526526

527527
**SQL:**
528-
[sql]
528+
[,sql]
529529
----
530530
SELECT name FROM person
531531
WHERE age > (SELECT AVG(age) FROM person);
@@ -548,7 +548,7 @@ select $avg, $name, $age;
548548
=== UNION → or patterns
549549

550550
**SQL:**
551-
[sql]
551+
[,sql]
552552
----
553553
SELECT name FROM person WHERE age < 25
554554
UNION
@@ -585,7 +585,7 @@ Both are valid!
585585
=== EXISTS → not { not { ... } }
586586

587587
**SQL:**
588-
[sql]
588+
[,sql]
589589
----
590590
SELECT name FROM person p
591591
WHERE EXISTS (
@@ -611,7 +611,7 @@ _This will be improved in future versions of TypeQL!_
611611
=== IN → multiple value constraints
612612

613613
**SQL:**
614-
[sql]
614+
[,sql]
615615
----
616616
SELECT name FROM person WHERE age IN (25, 30, 35);
617617
----
@@ -639,7 +639,7 @@ select $name;
639639
=== LIKE → like (regex)
640640

641641
**SQL:**
642-
[sql]
642+
[,sql]
643643
----
644644
SELECT name FROM person WHERE email LIKE '%@example.com';
645645
----
@@ -657,7 +657,7 @@ select $name;
657657
=== NULL checks → not { ... }
658658

659659
**SQL:**
660-
[sql]
660+
[,sql]
661661
----
662662
SELECT name FROM person WHERE email IS NULL;
663663
----
@@ -676,7 +676,7 @@ select $name;
676676
----
677677

678678
**SQL:**
679-
[sql]
679+
[,sql]
680680
----
681681
SELECT name FROM person WHERE email IS NOT NULL;
682682
----
@@ -726,7 +726,7 @@ match $avg_age > 29;
726726
In SQL, relationships are represented through foreign keys. In TypeQL, relationships are explicit relations that can have their own attributes and connect multiple entities.
727727

728728
**SQL (with foreign keys):**
729-
[sql]
729+
[,sql]
730730
----
731731
CREATE TABLE employment (
732732
id INT PRIMARY KEY,

0 commit comments

Comments
 (0)