From a04c9f2fb644b5554157d6c4d18a59ac1f3c1f33 Mon Sep 17 00:00:00 2001 From: Abdulazeez Abdulazeez Adeshina <31009679+Youngestdev@users.noreply.github.com> Date: Tue, 6 Jun 2023 13:02:05 +0100 Subject: [PATCH] Update coding.en.mdx Fixed typo and added language to MySQL code blocks. --- pages/applications/coding.en.mdx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pages/applications/coding.en.mdx b/pages/applications/coding.en.mdx index 8758eeb..1fa77b8 100644 --- a/pages/applications/coding.en.mdx +++ b/pages/applications/coding.en.mdx @@ -82,7 +82,7 @@ a, b): ## MySQL Query Generation -Besides the basic code generation example above, you can use the model to generated useful code that could be used in other aspects of programming like creating and testing MySQL queries. +Besides the basic code generation example above, you can use the model to generate useful code that could be used in other aspects of programming like creating and testing MySQL queries. Let's say you have a dataset with some information which you can include as part of the prompt and then instruct it to generate a specific query. For example: @@ -95,7 +95,7 @@ Create a MySQL query for all students in the Computer Science department ``` *Output:* -``` +```mysql SELECT students.StudentId, students.StudentName FROM students INNER JOIN departments @@ -105,7 +105,7 @@ WHERE departments.DepartmentName = 'Computer Science'; The model generates a query! However, in this example we made up the database so we don't have a database to test the generated query. If you are testing this example, it could be useful to have this database created. Fortunately, you can use ChatGPT to generate this for you as well. One approach is using a modified version of the prompt above with slightly different instructions to generate a database schema: -``` +```mysql Table departments, columns = [DepartmentId, DepartmentName] Table students, columns = [DepartmentId, StudentId, StudentName] Create a valid database schema with the above tables and columns @@ -113,7 +113,7 @@ Create a valid database schema with the above tables and columns The model generated the following schema: -``` +```mysql CREATE TABLE departments ( DepartmentId INT PRIMARY KEY, DepartmentName VARCHAR(50) @@ -131,7 +131,7 @@ You can create a temporary database using something like [sqliteonline.com](http You will also need dummy data to test if the original generated query was valid. Let's use ChatGPT for this too! The prompt could look something like the following: -``` +```mysql CREATE TABLE departments ( DepartmentId INT PRIMARY KEY, DepartmentName VARCHAR(50) @@ -149,7 +149,7 @@ Given the database schema above, generate valid insert statements include 4 rows The output with the insert statements: -``` +```mysql INSERT INTO departments (DepartmentId, DepartmentName) VALUES (1, 'Computer Science'), (2, 'Mathematics'), (3, 'Physics'), (4, 'Biology'); @@ -166,7 +166,7 @@ If you are using the same System Message from before, be careful of how you are *Prompt:* -``` +```mysql SELECT students.StudentId, students.StudentName FROM students INNER JOIN departments @@ -193,4 +193,4 @@ Example coming soon! Example coming soon! ## Best practices -Coming soon! \ No newline at end of file +Coming soon!