so I was trying to use if statement on MySQL. I have a table contains tp1 column and in this column I have two different string values L1_ON or L1_OFF, I want to get L1_ON if there is one on tp1 column but if there is no L1_ON just get L1_OFF. this is what wrote and i know it's not correct just for extra explanation.
$query1 = sprintf('SELECT id,dateandtime,tp1 FROM plate WHERE AND IF(tp1 LIKE "L1_ON") else (tp1 LIKE "L1_OFF") ORDER BY id ASC LIMIT 1');
source https://stackoverflow.com/questions/69772844/mysql-query-code-to-check-if-statement-and-get-row-values
Comments
Post a Comment