Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I want to find max lenght of string from a tabe in SQLite

SELECT MAX(SELECT MAX(LENGTH(`name`)) count FROM `student_info` 
UNION SELECT MAX(LENGTH(`address`)) count FROM `student_info` 
UNION SELECT MAX(LENGTH(`class`)) count FROM `student_info` 
UNION SELECT MAX(LENGTH(`roll`)) count FROM `student_info` 
UNION SELECT MAX(LENGTH(`subject`)) count FROM `student_info`) 
FROM `student_info`

by using similar type of query i want to find one max value of string so i can manage table properly.

what is the proper query for SQLite?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Your query is mostly correct , just make minor change like below

SELECT MAX(count) from (
  SELECT MAX(LENGTH(`name`)) count FROM `student_info` 
UNION SELECT MAX(LENGTH(`address`)) count FROM `student_info` 
UNION SELECT MAX(LENGTH(`class`)) count FROM `student_info` 
UNION SELECT MAX(LENGTH(`roll`)) count FROM `student_info` 
UNION SELECT MAX(LENGTH(`subject`)) count FROM `student_info`
) ;

Try Here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading