You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'or team_id2=) and confirm=1 order by bdate desc' at line 1select * from tb_score where (team_id1= or team_id2=) and confirm=1 order by bdate desc