adambard / learnxinyminutes-docs

Code documentation written as code! How novel and totally my idea!
https://learnxinyminutes.com/
Other
11.28k stars 3.28k forks source link

[sql/en] Broaden engine support and ANSI compatibility #4602

Open bowmanjd opened 1 year ago

bowmanjd commented 1 year ago

The SQL page is succinct and well designed, but I worry about the LIMIT clause. While supported by MySQL, MariaDB, and PostgreSQL, and SQLite, LIMIT is not standard ANSI SQL, and is notably not supported by Microsoft SQL Server (T-SQL).

I could submit a PR if appropriate, but would like to know if it is permissible to show two different options, for different database engines.

For instance, we could start with

SELECT * FROM departments ORDER BY dept_name OFFSET 0 ROWS FETCH NEXT 5 ROWS ONLY;

which is ANSI compliant and works on MariaDB, PostgreSQL, and SQL Server, then follow with something like

Some database engines such as MySQL And SQLite do not support ORDER BY... OFFSET... FETCH... and instead implement a LIMIT clause:

SELECT * FROM departments LIMIT 5

In related news, perhaps the whole article could lean harder toward PostgreSQL or MariaDB for compliance's sake? For instance, we could use the Chinook sample data, instead of a sample with MySQL-only instructions.

At the end of the day, I just really want to recommend learnxinyminutes to anyone, regardless of database engine.

nbehrnd commented 1 year ago

I could submit a PR if appropriate, but would like to know if it is permissible to show two different options, for different database engines.

My present perception is that anyone can prepare a PR to contribute to the project; in case suggesting improvement for an already existing page, the listed contributors to this very page [cf. header of the .md file] then can review the PR filed by you. Equally see file CONTRIBUTING.markdown as a guideline.

bowmanjd commented 1 year ago

That works for me. I can work on a PR, then let discussion stem from that. Thank you!

bowmanjd commented 1 year ago

I have submitted PR #4609 with a variety of changes to make the SQL instructions work across several different engines, including MySQL, MariaDB, PostgreSQL, Microsoft SQL Server, SQLite, IBM DB2, and Oracle. I welcome discussion, as there are several decisions that could be debated.

bowmanjd commented 1 year ago

I am happy to split this PR into multiple if that would be better. Just curious if anyone has input.