Govur University Logo
--> --> --> -->
...

Write a SQL fragment that filters a column named 'ProductName' to include only products containing the word 'Smart' but explicitly excluding any products also containing 'Smartphone'.



The SQL fragment to filter the 'ProductName' column as specified is: `WHERE ProductName LIKE '%Smart%' AND ProductName NOT LIKE '%Smartphone%'`. The `WHERE` clause is fundamental for filtering rows in SQL, specifying the conditions that must be met for a row to be included in the query result. `ProductName` refers to the specific column whose values are being evaluated against the given conditions. The `LIKE` operator is a SQL pattern matching operator used to compare a column value to a specified pattern. The percent sign (`%`) is a wildcard character that represents zero or more characters in the pattern; thus, `'%Smart%'` matches any string that contains the substring "Smart" anywhere within it, for example, "Smartwatch" or "Smart TV". The `AND` logical operator combines multiple conditional expressions, requiring all connected conditions to be true for a row to satisfy the `WHERE` clause. This ensures that a product name must both contain "Smart" and meet the subsequent exclusion condition. The `NOT LIKE` operator is the inverse of `LIKE`, used to find column values that do not match a specified pattern. Therefore, `NOT LIKE '%Smartphone%'` explicitly excludes any product names that contain the substring "Smartphone", such as "Smartphone Pro" or "Ultra Smartphone", even if they also contain "Smart", thereby fulfilling the exclusion requirement.