Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要验证 2 列,但有时第二列是空的,然后我需要验证第二列,如果它不为空,否则它只会验证第一列
SELECT * FROM table WHERE column1 = $_GET['id'] and column2 IS NOT NULL = $_GET['id']
这是你想要的逻辑吗?
SELECT * FROM table WHERE column1 = $_GET['id'] and (column2 IS NULL or column2 = $_GET['id']);
SELECT IF(column1 IS NULL, column2, column1) FROM table WHERE column1 = $_GET['id'] OR column2 = $_GET['id']