Using if in where clause with datatable editor
Using if in where clause with datatable editor
kharismatics
Posts: 6Questions: 2Answers: 0
How can i use if condition with WHERE CLAUSE of datatable editor
here is the query example
SELECT
*
FROM
tablename
WHERE IF(category=1, rule = 1, rule = 2)
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
->where( function ( $q ) {
$q
->where( "IF(category=1,rule = 1,rule = 2)", "if(1=1,1,0)", "=", false );
})
im using this right now but i think there is a better way
I think the only better way would be to use a VIEW. There aren't any methods in the database abstraction to apply
if
conditions in the SQL.Allan
thanks @allan for the suggestion