Contd: Demo: Query Language Cheatsheet Generation using ChatGPT 3.5

On 5/3/23 7:41 AM, 'Kingsley Idehen' via ontolog-forum wrote:

>> Hi Kingsley
>>
>> I tried your examples out on the DBpedia SPARQL endpoint 
>> (https://dbpedia.org/sparql). Thank you. I have never tried SPARQL 
>> before so it was a great introduction to the language. Some of this 
>> ontology stuff is like speaking Klingon on a bad day. But not SPARQL :)
>>
>>
>> Mike
>>
> Hi Mike,
>
> Great to hear!
>
> All:
>
> Here’s a tweak to the SPARQL Cheatsheet that lets you simply click on 
> a hyperlink that denotes a usage-example query solution page.
>
>     Create a rendition using these guidelines, for the first 5 rows:
>
>      1. Create a DBpedia SPARQL URL from the Example column values
>         within quotations
>      2. Use the URL to hyperlink values in the “Command” Column
>
> Command  Description  Example
> SELECT 
> <http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=SELECT%20%3Fname%20WHERE%20%7B%20%3Fs%20dbo%3AbirthPlace%20dbr%3AGermany%3B%20foaf%3Aname%20%3Fname%20%7D%20LIMIT%2010&format=text%2Fhtml> 
>  Retrieves values by matching a query pattern. Returns a table with 
> variables and their bindings.  SELECT ?name WHERE { ?s dbo:birthPlace 
> dbr:Germany; foaf:name ?name } LIMIT 10
> ASK 
> <http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=ASK%20%7B%20dbr%3AAlbert_Einstein%20dbo%3AbirthPlace%20dbr%3AGermany%20%7D&format=text%2Fhtml> 
>  Tests whether a query pattern has a solution. Returns a boolean value 
> (true or false).  ASK { dbr:Albert_Einstein dbo:birthPlace dbr:Germany }
> DESCRIBE 
> <http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=DESCRIBE%20dbr%3AAlbert_Einstein&format=text%2Fhtml> 
>  Retrieves information about resources in the RDF graph. Returns an 
> RDF graph as the result.  DESCRIBE dbr:Albert_Einstein
> CONSTRUCT 
> <http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=CONSTRUCT%20%7B%20%3Fs%20a%20foaf%3APerson%20%7D%20WHERE%20%7B%20%3Fs%20a%20foaf%3APerson%20%7D%20LIMIT%2010&format=text%2Fhtml> 
>  Constructs an RDF graph based on the query pattern. Returns an RDF 
> graph as the result.  CONSTRUCT { ?s a foaf:Person } WHERE { ?s a 
> foaf:Person } LIMIT 10
> SAMPLE() 
> <http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=SELECT%20(SAMPLE(%3Fname)%20AS%20%3Fsample_name)%20WHERE%20%7B%20%3Fs%20foaf%3Aname%20%3Fname%20%7D%20GROUP%20BY%20%3Fs&format=text%2Fhtml> 
>  Returns an arbitrary value from a group of values. Useful for 
> selecting a single value per group.  SELECT (SAMPLE(?name) AS 
> ?sample_name) WHERE { ?s foaf:name ?name } GROUP BY ?s
>
>     Q: Repeat, but for the next 4 rows.
>
> Command  Description  Example
> COUNT() 
> <http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=SELECT%20(COUNT(%3Fs)%20AS%20%3Fcount)%20WHERE%20%7B%20%3Fs%20a%20dbo%3AScientist%20%7D&format=text%2Fhtml> 
>  Counts the number of solutions that match the query pattern. Returns 
> an integer value.  SELECT (COUNT(?s) AS ?count) WHERE { ?s a 
> dbo:Scientist }
> FILTER 
> <http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=SELECT%20%3Fname%20WHERE%20%7B%20%3Fs%20dbo%3AbirthPlace%20dbr%3AGermany%3B%20foaf%3Aname%20%3Fname%20FILTER%20(lang(%3Fname)%20%3D%20%22en%22)%20%7D&format=text%2Fhtml> 
>  Filters query results based on a condition. Excludes solutions that 
> do not satisfy the condition.  SELECT ?name WHERE { ?s dbo:birthPlace 
> dbr:Germany; foaf:name ?name FILTER (lang(?name) = “en”) }
> OPTIONAL 
> <http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=SELECT%20%3Fname%20%3FbirthDate%20WHERE%20%7B%20%3Fs%20foaf%3Aname%20%3Fname%20OPTIONAL%20%7B%20%3Fs%20dbo%3AbirthDate%20%3FbirthDate%20%7D%20%7D%20LIMIT%2010&format=text%2Fhtml> 
>  Allows parts of a query to be optional. If the optional part has no 
> match, the query still succeeds.  SELECT ?name ?birthDate WHERE { ?s 
> foaf:name ?name OPTIONAL { ?s dbo:birthDate ?birthDate } } LIMIT 10
> ORDER BY 
> <http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=SELECT%20%3Fname%20%3FbirthDate%20WHERE%20%7B%20%3Fs%20foaf%3Aname%20%3Fname%3B%20dbo%3AbirthDate%20%3FbirthDate%20%7D%20ORDER%20BY%20%3FbirthDate&format=text%2Fhtml> 
>  Orders the query results based on the specified variable(s). Can 
> order in ascending or descending.  SELECT ?name ?birthDate WHERE { ?s 
> foaf:name ?name; dbo:birthDate ?birthDate } ORDER BY ?birthDate
>
>     Q: Repeat, for the next 4 rows.
>
> Command  Description  Example
> GROUP BY 
> <http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=SELECT%20%3FbirthPlace%20(COUNT(%3Fs)%20AS%20%3Fcount)%20WHERE%20%7B%20%3Fs%20dbo%3AbirthPlace%20%3FbirthPlace%3B%20a%20dbo%3AScientist%20%7D%20GROUP%20BY%20%3FbirthPlace&format=text%2Fhtml> 
>  Groups the query results by one or more variables and applies an 
> aggregate function to each group.  SELECT ?birthPlace (COUNT(?s) AS 
> ?count) WHERE { ?s dbo:birthPlace ?birthPlace; a dbo:Scientist } GROUP 
> BY ?birthPlace
> HAVING 
> <http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=SELECT%20%3FbirthPlace%20(COUNT(%3Fs)%20AS%20%3Fcount)%20WHERE%20%7B%20%3Fs%20dbo%3AbirthPlace%20%3FbirthPlace%3B%20a%20dbo%3AScientist%20%7D%20GROUP%20BY%20%3FbirthPlace%20HAVING%20(COUNT(%3Fs)%20%3E%205)&format=text%2Fhtml> 
>  Filters the results of a GROUP BY query based on a condition. 
> Excludes groups that do not satisfy the condition.  SELECT ?birthPlace 
> (COUNT(?s) AS ?count) WHERE { ?s dbo:birthPlace ?birthPlace; a 
> dbo:Scientist } GROUP BY ?birthPlace HAVING (COUNT(?s) > 5)
> DESCRIBE 
> <http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=DESCRIBE%20dbr%3AAlbert_Einstein&format=text%2Fhtml> 
>  Provides an RDF graph that describes the resources found.  DESCRIBE 
> dbr:Albert_Einstein
> CONSTRUCT 
> <http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=CONSTRUCT%20%7B%20%3Fs%20a%20dbo%3AScientist%20%7D%20WHERE%20%7B%20%3Fs%20a%20dbo%3AScientist%20%7D&format=text%2Fhtml> 
>  Constructs an RDF graph based on the query pattern.  CONSTRUCT { ?s a 
> dbo:Scientist } WHERE { ?s a dbo:Scientist }
>
>
>
Here’s the SQL variant of the hyperlink-enhanced SPARQL Cheatsheet 
generated by ChatGPT.


      Testing ANSI SQL Query Examples

    Q: Redo, using these guidelines, for the first 3 rows:

     1.

        Set the Virtuoso SPASQL Query Service URL to https:
        //demo.openlinksw.com/spasqlqb/

     2.

        Qualify Table Names portion of the quoted values in “Example”
        column by adding Demo.Demo (representing Database and Schema
        respectively)

     3.

        Use “Example” column values within quotations as values of for
        “sql” key in the JSON structure that follows
        {
        “v”: 1,
        “url”: “/XMLA”,
        “dsn”: “DSN=Local_Instance”,
        “uid”: “demo”,
        “pwd”: “demo”,
        “path”: null,
        “tab”: “exec”,
        “idx”: null,
        “fkey”: null,
        “ref”: null,
        “exec”: {
        “sql”: “SELECT ProductName FROM Demo..Products WHERE CategoryID
        = 1 UNION SELECT ProductName FROM Demo..Products WHERE
        CategoryID = 2\n”
        }
        }

     4.

        Create an encoded Virtuoso SPASQL Query Service URL using JSON
        structure as the value for the ?permlink_e parameter

     5.

        Use the constructed Virtuoso SPASQL Query Service URL to
        hyperlink values in the “Command” Column

     6.

        Output to a Markdown Table in a code-block

Command  Description  Example
SELECT 
<https://demo.openlinksw.com/spasqlqb/?permlink_e=%7B%22v%22%3A1%2C%22url%22%3A%22%2FXMLA%22%2C%22dsn%22%3A%22DSN%3DLocal_Instance%22%2C%22uid%22%3A%22demo%22%2C%22pwd%22%3A%22demo%22%2C%22path%22%3Anull%2C%22tab%22%3A%22exec%22%2C%22idx%22%3Anull%2C%22fkey%22%3Anull%2C%22ref%22%3Anull%2C%22exec%22%3A%7B%22sql%22%3A%22SELECT%20CompanyName%2C%20ContactName%20FROM%20Demo.Demo.Customers%22%7D%7D> 
 Retrieves data from one or more tables  |SELECT CompanyName, 
ContactName FROM Demo.Demo.Customers|
DISTINCT 
<https://demo.openlinksw.com/spasqlqb/?permlink_e=%7B%22v%22%3A1%2C%22url%22%3A%22%2FXMLA%22%2C%22dsn%22%3A%22DSN%3DLocal_Instance%22%2C%22uid%22%3A%22demo%22%2C%22pwd%22%3A%22demo%22%2C%22path%22%3Anull%2C%22tab%22%3A%22exec%22%2C%22idx%22%3Anull%2C%22fkey%22%3Anull%2C%22ref%22%3Anull%2C%22exec%22%3A%7B%22sql%22%3A%22SELECT%20DISTINCT%20Country%20FROM%20Demo.Demo.Customers%22%7D%7D> 
 Retrieves unique values  |SELECT DISTINCT Country FROM 
Demo.Demo.Customers|
WHERE 
<https://demo.openlinksw.com/spasqlqb/?permlink_e=%7B%22v%22%3A1%2C%22url%22%3A%22%2FXMLA%22%2C%22dsn%22%3A%22DSN%3DLocal_Instance%22%2C%22uid%22%3A%22demo%22%2C%22pwd%22%3A%22demo%22%2C%22path%22%3Anull%2C%22tab%22%3A%22exec%22%2C%22idx%22%3Anull%2C%22fkey%22%3Anull%2C%22ref%22%3Anull%2C%22exec%22%3A%7B%22sql%22%3A%22SELECT%20ProductName%2C%20UnitPrice%20FROM%20Demo.Demo.Products%20WHERE%20CategoryID%20%3D%202%22%7D%7D> 
 Filters query results based on a condition  |SELECT ProductName, 
UnitPrice FROM Demo.Demo.Products WHERE CategoryID = 2|

    Q: Redo for the next 3 rows.
    Q: Redo “LIKE” command row.

Command  Description  Example
AND/OR 
<https://demo.openlinksw.com/spasqlqb/?permlink_e=%7B%22v%22%3A1%2C%22url%22%3A%22%2FXMLA%22%2C%22dsn%22%3A%22DSN%3DLocal_Instance%22%2C%22uid%22%3A%22demo%22%2C%22pwd%22%3A%22demo%22%2C%22path%22%3Anull%2C%22tab%22%3A%22exec%22%2C%22idx%22%3Anull%2C%22fkey%22%3Anull%2C%22ref%22%3Anull%2C%22exec%22%3A%7B%22sql%22%3A%22SELECT%20ProductName%2C%20UnitPrice%20FROM%20Demo.Demo.Products%20WHERE%20CategoryID%20%3D%202%20AND%20UnitsInStock%20%3E%200%22%7D%7D> 
 Combines multiple conditions  |SELECT ProductName, UnitPrice FROM 
Demo.Demo.Products WHERE CategoryID = 2 AND UnitsInStock > 0|
IN 
<https://demo.openlinksw.com/spasqlqb/?permlink_e=%7B%22v%22%3A1%2C%22url%22%3A%22%2FXMLA%22%2C%22dsn%22%3A%22DSN%3DLocal_Instance%22%2C%22uid%22%3A%22demo%22%2C%22pwd%22%3A%22demo%22%2C%22path%22%3Anull%2C%22tab%22%3A%22exec%22%2C%22idx%22%3Anull%2C%22fkey%22%3Anull%2C%22ref%22%3Anull%2C%22exec%22%3A%7B%22sql%22%3A%22SELECT%20ProductName%20FROM%20Demo.Demo.Products%20WHERE%20SupplierID%20IN%20%281%2C%202%2C%203%29%22%7D%7D> 
 Retrieves values that match a list of specified values  |SELECT 
ProductName FROM Demo.Demo.Products WHERE SupplierID IN (1, 2, 3)|
LIKE 
<https://demo.openlinksw.com/spasqlqb/?permlink_e=%7B%22v%22%3A1%2C%22url%22%3A%22%2FXMLA%22%2C%22dsn%22%3A%22DSN%3DLocal_Instance%22%2C%22uid%22%3A%22demo%22%2C%22pwd%22%3A%22demo%22%2C%22path%22%3Anull%2C%22tab%22%3A%22exec%22%2C%22idx%22%3Anull%2C%22fkey%22%3Anull%2C%22ref%22%3Anull%2C%22exec%22%3A%7B%22sql%22%3A%22SELECT%20ProductName%20FROM%20Demo.Demo.Products%20WHERE%20ProductName%20LIKE%20%27%25Chai%25%27%22%7D%7D> 
 Retrieves values that match a specified pattern  |SELECT ProductName 
FROM Demo.Demo.Products WHERE ProductName LIKE '%Chai%'|

    Q: Repeat for the next 3 rows.
    Q: Redo “HAVING” command row.

Command  Description  Example
ORDER BY 
<https://demo.openlinksw.com/spasqlqb/?permlink_e=%7B%22v%22%3A1%2C%22url%22%3A%22%2FXMLA%22%2C%22dsn%22%3A%22DSN%3DLocal_Instance%22%2C%22uid%22%3A%22demo%22%2C%22pwd%22%3A%22demo%22%2C%22path%22%3Anull%2C%22tab%22%3A%22exec%22%2C%22idx%22%3Anull%2C%22fkey%22%3Anull%2C%22ref%22%3Anull%2C%22exec%22%3A%7B%22sql%22%3A%22SELECT%20ProductName%2C%20UnitPrice%20FROM%20Demo.Demo.Products%20ORDER%20BY%20UnitPrice%20DESC%22%7D%7D> 
 Sorts the query results  |SELECT ProductName, UnitPrice FROM 
Demo.Demo.Products ORDER BY UnitPrice DESC|
GROUP BY 
<https://demo.openlinksw.com/spasqlqb/?permlink_e=%7B%22v%22%3A1%2C%22url%22%3A%22%2FXMLA%22%2C%22dsn%22%3A%22DSN%3DLocal_Instance%22%2C%22uid%22%3A%22demo%22%2C%22pwd%22%3A%22demo%22%2C%22path%22%3Anull%2C%22tab%22%3A%22exec%22%2C%22idx%22%3Anull%2C%22fkey%22%3Anull%2C%22ref%22%3Anull%2C%22exec%22%3A%7B%22sql%22%3A%22SELECT%20CategoryID%2C%20COUNT%28%2A%29%20FROM%20Demo.Demo.Products%20GROUP%20BY%20CategoryID%22%7D%7D> 
 Groups query results based on a variable  |SELECT CategoryID, COUNT(*) 
FROM Demo.Demo.Products GROUP BY CategoryID|
HAVING 
<https://demo.openlinksw.com/spasqlqb/?permlink_e=%7B%22v%22%3A1%2C%22url%22%3A%22%2FXMLA%22%2C%22dsn%22%3A%22DSN%3DLocal_Instance%22%2C%22uid%22%3A%22demo%22%2C%22pwd%22%3A%22demo%22%2C%22path%22%3Anull%2C%22tab%22%3A%22exec%22%2C%22idx%22%3Anull%2C%22fkey%22%3Anull%2C%22ref%22%3Anull%2C%22exec%22%3A%7B%22sql%22%3A%22SELECT%20CategoryID%2C%20COUNT%28%2A%29%20FROM%20Demo.Demo.Products%20GROUP%20BY%20CategoryID%20HAVING%20COUNT%28%2A%29%20%3E%205%22%7D%7D> 
 Filters groups based on a condition  |SELECT CategoryID, COUNT(*) FROM 
Demo.Demo.Products GROUP BY CategoryID HAVING COUNT(*) > 5|

    Q: Redo for next 3 rows.
    Q: Redo “LEFT JOIN” row.

Command  Description  Example
JOIN 
<https://demo.openlinksw.com/spasqlqb/?permlink_e=%7B%22v%22%3A1%2C%22url%22%3A%22%2FXMLA%22%2C%22dsn%22%3A%22DSN%3DLocal_Instance%22%2C%22uid%22%3A%22demo%22%2C%22pwd%22%3A%22demo%22%2C%22path%22%3Anull%2C%22tab%22%3A%22exec%22%2C%22idx%22%3Anull%2C%22fkey%22%3Anull%2C%22ref%22%3Anull%2C%22exec%22%3A%7B%22sql%22%3A%22SELECT%20Orders.OrderID%2C%20Customers.CompanyName%20FROM%20Demo.Demo.Orders%20JOIN%20Demo.Demo.Customers%20ON%20Orders.CustomerID%20%3D%20Customers.CustomerID%22%7D%7D> 
 Combines data from two or more tables based on a related column 
|SELECT Orders.OrderID, Customers.CompanyName FROM Demo.Demo.Orders JOIN 
Demo.Demo.Customers ON Orders.CustomerID = Customers.CustomerID|
INNER JOIN 
<https://demo.openlinksw.com/spasqlqb/?permlink_e=%7B%22v%22%3A1%2C%22url%22%3A%22%2FXMLA%22%2C%22dsn%22%3A%22DSN%3DLocal_Instance%22%2C%22uid%22%3A%22demo%22%2C%22pwd%22%3A%22demo%22%2C%22path%22%3Anull%2C%22tab%22%3A%22exec%22%2C%22idx%22%3Anull%2C%22fkey%22%3Anull%2C%22ref%22%3Anull%2C%22exec%22%3A%7B%22sql%22%3A%22SELECT%20OrderID%2C%20ProductName%20FROM%20Demo.Demo.OrderDetails%20INNER%20JOIN%20Demo.Demo.Products%20ON%20OrderDetails.ProductID%20%3D%20Products.ProductID%22%7D%7D> 
 Returns only the rows that have matching values in both tables  |SELECT 
OrderID, ProductName FROM Demo.Demo.OrderDetails INNER JOIN 
Demo.Demo.Products ON OrderDetails.ProductID = Products.ProductID|
LEFT JOIN 
<https://demo.openlinksw.com/spasqlqb/?permlink_e=%7B%22v%22%3A1%2C%22url%22%3A%22%2FXMLA%22%2C%22dsn%22%3A%22DSN%3DLocal_Instance%22%2C%22uid%22%3A%22demo%22%2C%22pwd%22%3A%22demo%22%2C%22path%22%3Anull%2C%22tab%22%3A%22exec%22%2C%22idx%22%3Anull%2C%22fkey%22%3Anull%2C%22ref%22%3Anull%2C%22exec%22%3A%7B%22sql%22%3A%22SELECT%20Customers.CompanyName%2C%20Orders.OrderID%20FROM%20Demo.Demo.Customers%20LEFT%20JOIN%20Demo.Demo.Orders%20ON%20Customers.CustomerID%20%3D%20Orders.CustomerID%22%7D%7D> 
 Returns all rows from the left table and the matched rows from the 
right table  |SELECT Customers.CompanyName, Orders.OrderID FROM 
Demo.Demo.Customers LEFT JOIN Demo.Demo.Orders ON Customers.CustomerID = 
Orders.CustomerID|

    Q: Redo for next 3 rows.
    Q: Redo “UNION” row.

Command  Description  Example
RIGHT JOIN 
<https://demo.openlinksw.com/spasqlqb/?permlink_e=%7B%22v%22%3A1%2C%22url%22%3A%22%2FXMLA%22%2C%22dsn%22%3A%22DSN%3DLocal_Instance%22%2C%22uid%22%3A%22demo%22%2C%22pwd%22%3A%22demo%22%2C%22path%22%3Anull%2C%22tab%22%3A%22exec%22%2C%22idx%22%3Anull%2C%22fkey%22%3Anull%2C%22ref%22%3Anull%2C%22exec%22%3A%7B%22sql%22%3A%22SELECT%20Orders.OrderID%2C%20OrderDetails.ProductID%20FROM%20Demo.Demo.Orders%20RIGHT%20JOIN%20Demo.Demo.OrderDetails%20ON%20Orders.OrderID%20%3D%20OrderDetails.OrderID%22%7D%7D> 
 Returns all rows from the right table and the matched rows from the 
left table  |SELECT Orders.OrderID, OrderDetails.ProductID FROM 
Demo.Demo.Orders RIGHT JOIN Demo.Demo.OrderDetails ON Orders.OrderID = 
OrderDetails.OrderID|
FULL OUTER JOIN 
<https://demo.openlinksw.com/spasqlqb/?permlink_e=%7B%22v%22%3A1%2C%22url%22%3A%22%2FXMLA%22%2C%22dsn%22%3A%22DSN%3DLocal_Instance%22%2C%22uid%22%3A%22demo%22%2C%22pwd%22%3A%22demo%22%2C%22path%22%3Anull%2C%22tab%22%3A%22exec%22%2C%22idx%22%3Anull%2C%22fkey%22%3Anull%2C%22ref%22%3Anull%2C%22exec%22%3A%7B%22sql%22%3A%22SELECT%20Customers.CompanyName%2C%20Orders.OrderID%20FROM%20Demo.Demo.Customers%20FULL%20OUTER%20JOIN%20Demo.Demo.Orders%20ON%20Customers.CustomerID%20%3D%20Orders.CustomerID%22%7D%7D> 
 Returns all rows from both tables and matches them where possible 
|SELECT Customers.CompanyName, Orders.OrderID FROM Demo.Demo.Customers 
FULL OUTER JOIN Demo.Demo.Orders ON Customers.CustomerID = 
Orders.CustomerID|
UNION 
<https://demo.openlinksw.com/spasqlqb/?permlink_e=%7B%22v%22%3A1%2C%22url%22%3A%22%2FXMLA%22%2C%22dsn%22%3A%22DSN%3DLocal_Instance%22%2C%22uid%22%3A%22demo%22%2C%22pwd%22%3A%22demo%22%2C%22path%22%3Anull%2C%22tab%22%3A%22exec%22%2C%22idx%22%3Anull%2C%22fkey%22%3Anull%2C%22ref%22%3Anull%2C%22exec%22%3A%7B%22sql%22%3A%22SELECT%20ProductName%20FROM%20Demo.Demo.Products%20WHERE%20CategoryID%20%3D%201%20UNION%20SELECT%20ProductName%20FROM%20Demo.Demo.Products%20WHERE%20CategoryID%20%3D%202%22%7D%7D> 
 Combines the results of two or more SELECT statements  |SELECT 
ProductName FROM Demo.Demo.Products WHERE CategoryID = 1 UNION SELECT 
ProductName FROM Demo.Demo.Products WHERE CategoryID = 2|

    Q: Redo for the next 3 rows.
    Q: Redo “DELETE FROM” row.

Command  Description  Example
INSERT INTO 
<https://demo.openlinksw.com/spasqlqb/?permlink_e=%7B%22v%22%3A1%2C%22url%22%3A%22%2FXMLA%22%2C%22dsn%22%3A%22DSN%3DLocal_Instance%22%2C%22uid%22%3A%22demo%22%2C%22pwd%22%3A%22demo%22%2C%22path%22%3Anull%2C%22tab%22%3A%22exec%22%2C%22idx%22%3Anull%2C%22fkey%22%3Anull%2C%22ref%22%3Anull%2C%22exec%22%3A%7B%22sql%22%3A%22INSERT%20INTO%20Demo.Demo.Customers%20(CustomerID%2C%20CompanyName%2C%20ContactName)%20VALUES%20(%27ALFKI%27%2C%20%27Alfreds%20Futterkiste%27%2C%20%27Maria%20Anders%27)%22%7D%7D> 
 Inserts new data into a table  |INSERT INTO Demo.Demo.Customers 
(CustomerID, CompanyName, ContactName) VALUES ('ALFKI', 'Alfreds 
Futterkiste', 'Maria Anders')|
UPDATE 
<https://demo.openlinksw.com/spasqlqb/?permlink_e=%7B%22v%22%3A1%2C%22url%22%3A%22%2FXMLA%22%2C%22dsn%22%3A%22DSN%3DLocal_Instance%22%2C%22uid%22%3A%22demo%22%2C%22pwd%22%3A%22demo%22%2C%22path%22%3Anull%2C%22tab%22%3A%22exec%22%2C%22idx%22%3Anull%2C%22fkey%22%3Anull%2C%22ref%22%3Anull%2C%22exec%22%3A%7B%22sql%22%3A%22UPDATE%20Demo.Demo.Products%20SET%20UnitPrice%20%3D%2020%20WHERE%20ProductName%20%3D%20%27Chai%27%22%7D%7D> 
 Modifies existing data in a table  |UPDATE Demo.Demo.Products SET 
UnitPrice = 20 WHERE ProductName = 'Chai'|
DELETE FROM 
<https://demo.openlinksw.com/spasqlqb/?permlink_e=%7B%22v%22%3A1%2C%22url%22%3A%22%2FXMLA%22%2C%22dsn%22%3A%22DSN%3DLocal_Instance%22%2C%22uid%22%3A%22demo%22%2C%22pwd%22%3A%22demo%22%2C%22path%22%3Anull%2C%22tab%22%3A%22exec%22%2C%22idx%22%3Anull%2C%22fkey%22%3Anull%2C%22ref%22%3Anull%2C%22exec%22%3A%7B%22sql%22%3A%22DELETE%20FROM%20Demo.Demo.Customers%20WHERE%20CustomerID%20%3D%20%27ALFKI%27%22%7D%7D> 
 Deletes data from a table  |DELETE FROM Demo.Demo.Customers WHERE 
CustomerID = 'ALFKI'|

​

-- 
Regards,

Kingsley Idehen 
Founder & CEO
OpenLink Software
Home Page:http://www.openlinksw.com
Community Support:https://community.openlinksw.com
Weblogs (Blogs):
Company Blog:https://medium.com/openlink-software-blog
Virtuoso Blog:https://medium.com/virtuoso-blog
Data Access Drivers Blog:https://medium.com/openlink-odbc-jdbc-ado-net-data-access-drivers

Personal Weblogs (Blogs):
Medium Blog:https://medium.com/@kidehen
Legacy Blogs:http://www.openlinksw.com/blog/~kidehen/
               http://kidehen.blogspot.com

Profile Pages:
Pinterest:https://www.pinterest.com/kidehen/
Quora:https://www.quora.com/profile/Kingsley-Uyi-Idehen
Twitter:https://twitter.com/kidehen
Google+:https://plus.google.com/+KingsleyIdehen/about
LinkedIn:http://www.linkedin.com/in/kidehen

Web Identities (WebID):
Personal:http://kingsley.idehen.net/public_home/kidehen/profile.ttl#i
         :http://id.myopenlink.net/DAV/home/KingsleyUyiIdehen/Public/kingsley.ttl#this

Received on Wednesday, 3 May 2023 21:09:16 UTC