Recently I came across with the following quiz. Imagine we have this table
+--------+
| colors |
+--------+
| red |
| black |
| white |
| green |
| orange |
+--------+
The task is to write a SQL query that will select all pairs without allowing duplicates. Permutations are counted too ({red, black} = {black, red}, hence only one of the pair is allowed).
Answer: SQL is a Structured Query Language that is used for manipulating and accessing the relational database. On the other hand, MySQL itself is a relational database that uses SQL as the standard database language.
So try to memorise the following consecutive statements: SELECT→FROM→WHERE. Next, remember that the SELECT statement refers to the column names, the FROM keyword refers to the table/database used, and the WHERE clause refers to specific conditions that are investigated by the user.
Try this
Select A.Color, B.Color
From Colors A
Cross Join Colors B
Where A.Color > B.Color
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With