Skip to content
Advertisement

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, ' ', '*');

Advertisement

Answer

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'
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement