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

Can I combine more than one function in a single line in SQL?

What I want to do is simply to use more than 1 function in a single query. I’m new to SQL so I’m sorry if I’m getting some words wrong.

select cognom from emp where length(cognom) = 10, replace(cognom, ' ', '*');

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 :

Yes, you can, as long as you respect the syntax. The ‘line’ does not mean anything because you can write all your query in a single line, even if it’s not recommended to facilitate the comprehension.
In your case, what its wrong is your replace() that should either be in the select part to manipulate output data, or match a where statement.
In fact, you can have as many function as you need, which could be something like this:

SELECT col1, func1(col2) as txt2, func2(col3) as text3
  FROM your_table
 WHERE col1 = 12
   AND func4(col5) = 'XYZ'
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