'Write query with subquery in CodeIgniter4 Query Builder?
I have the following query which has an issue with Query Builder.
SELECT IIF(ISNULL(MAX(CODCLIENTE), 0) + 1 = 1,
(SELECT VALOR + 1
FROM PARAMETROS
WHERE LTRIM(RTRIM(SUBCLAVE)) = 'MINIM'
AND USUARIO = '1'),
ISNULL(MAX(CODCLIENTE), 0) + 1)
FROM CLIENTES
WHERE CODCLIENTE >= (SELECT VALOR
FROM PARAMETROS
WHERE LTRIM(RTRIM(SUBCLAVE)) = 'MINIM'
AND USUARIO = '1')
AND CODCLIENTE <= (SELECT VALOR
FROM PARAMETROS
WHERE LTRIM(RTRIM(SUBCLAVE)) = 'MAXIM'
AND USUARIO = '1');
Is there any way to do it with Query Builder? I'm currently using this method.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
