1)There are many instances where tables could be joined on something other than keys. One example
would be joining two tables based on a common pattern in their column values. If you have two tables
and one has information about products and another has information about customers, you could join
these tables based on a matching keyword.
As an english sentence it would look something like: Join the table products to the table customers based on words from the description column matching words to the customer interests column.
In SQL, it would look like:
SELECT *
FROM products
JOIN customers
ON products.description LIKE '%' || customers.interests || '%';
The wild card % operator matches a common phrase or word with any text before or after the keyword.
2) Using SQL as a query language is interesting to use. I think it is relatively easy starting off, but as things get more complex in the language it gets messier to deal with. When translating from English to SQL what I find most challenging is just simply figuring out the right key words to use, or the right order of things. Before I got help from the TA Sabrina, I was very confused on how the joins worked but as she showed me through her own example it became more clear how I am to order the joins and use them. Now, as things get more complex, it is necessary I really learn the material so that it's not as challenging as it could be.
No comments:
Post a Comment