I need to show the results from this column where Product_name column contains 'Documentation' or 'documentation' in a result. The query must return a result regardless of whether the word is in lowercase or uppercase
https://i.stack.imgur.com/bjLuY.png
SELECT UPPER(PROD_NAME)as PROD_NAME, LENGTH(PROD_NAME) as PROD_NAME_LEN
FROM PRODUCTS
WHERE (PROD_NAME like '%Documentation%'
or PROD_NAME like '%DOCUMETATION%')
and LENGTH(PROD_NAME) <= 35
order by 2 DESC;
I found this solution, any suggestions
CodePudding user response:
SELECT UPPER(PROD_NAME)as PROD_NAME, LENGTH(PROD_NAME) as PROD_NAME_LEN
FROM PRODUCTS
WHERE lower(PROD_NAME) like '%documentation%'
and LENGTH(PROD_NAME) <= 35
order by 2 DESC;
CodePudding user response:
When I use PHP with MySQL, I personly use something like:
$setgeneral=$db->prepare("SELECT * FROM general where general_id=:general_id");
$setgeneral->execute(array('general_id' => 0));
$getgeneral=$setgeneral->fetch(PDO::FETCH_ASSOC);
That code takes the "general" table and brings a row/rows that has general_id=0. Well, it is not for only id's. You can use it for prod_name too!