I am trying to combine these MySQL queries but not getting them right. Here is the pseudocode that I am hoping to combine to get a single line sql statement.
$var1 = "abc"
$var2 = "def"
IF ( $var1 IN (SELECT DISTINCT col1 FROM t1) )
{
SELECT colA, colB, colC FROM t1 WHERE col1 = $var1 AND col2 LIKE '%$var2%'
}
ELSE
{
SELECT colA, colB, ColC FROM t1 WHERE col2 LIKE %$var1%
}
Thanks
SELECT IF('$var1' IN (SELECT DISTINCT col1 FROM t1), (colA, colB, colC), ) FROM t1but I get lost in the flow for the if statements