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.
我有一个问题,我必须进行查询,我必须在列中显示值“是”或“否”,具体取决于产品上是否有图像。我必须加入产品表,这是安全的,但我如何在查询中判断“图像存在”字段是否不为空,写“否”,否则写“是”。我希望我已经解释过了。谢谢你们。
您可以使用 CASE 语句,这是 w3schools 的一个简单示例
SELECT CustomerName, City, Country FROM Customers ORDER BY (CASE WHEN City IS NULL THEN Country ELSE City END);
需要注意的是,根据您使用的 DBMS,语法可能(或可能不)不同
https://www.w3schools.com/sql/sql_case.asp