What’s the most efficient way to get two queries based on an if statement?

What’s the most efficient way to get two queries based on an if statement?

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)