很抱歉,如果这是重复的,但是当我使用诸如concat(column1, column2) as column3
之类的解决方案时,我会得到奇怪的值。
我的数据如下:
Table1.Column1 Table2.Column2
A NULL
B NULL
NULL C
NULL D
E NULL
注意:只有1列具有NULL值。
我想要以下内容:
Column3
A
B
C
D
E
两列之一具有NULL值的属性将成立。这只是糟糕的表/列设计,因为它本来应该是一个表,但实际上不是。我不允许更改架构,也不允许插入/更新值。我只允许进行明智的查询,以理智的方式检索数据。
答案 0 :(得分:1)
您可以使用COALESCE
处理NULL
值:
SELECT CONCAT(COALESCE(Table1.Column1, ''), COALESCE(Table2.Column2, '') AS Column3
FROM ...
答案 1 :(得分:1)
您可以使用if语句。
public class GameController : MonoBehaviour {
[SerializeField] private Text questionText;
[SerializeField] private Text scoreText;
private DataController dataController;
private RoundData currentRoundData;
private QuestionData[] questionPool;
private AnswerData answerData;
private AnswerButton answerButton;
public GameObject questionDisplay;
public GameObject roundEndDisplay;
private bool isRoundActive;
private float timeRemaining;
private int questionIndex;
private int playerScore;
private void Start()
{
dataController = FindObjectOfType<DataController>();
currentRoundData = dataController.GetCurrentRoundData();
questionPool = currentRoundData.questions;
timeRemaining = currentRoundData.timeLimitInSeconds;
playerScore = 0;
questionIndex = 0;
ShowQuestion();
isRoundActive = true;
}
private void ShowQuestion()
{
QuestionData questionData = questionPool[questionIndex];
questionText.text = questionData.questionText;
answerButton.Setup(answerData);
}
public void AnswerButtonClicked(bool isCorrect)
{
if (isCorrect)
{
playerScore += currentRoundData.pointsAddedForCorrectAnswer;
scoreText.text = "Score: " + playerScore.ToString();
}
if (questionPool.Length > questionIndex + 1)
{
questionIndex++;
ShowQuestion();
} else
{
EndRound();
}
}
public void EndRound()
{
isRoundActive = false;
questionDisplay.SetActive(false);
roundEndDisplay.SetActive(true);
}
}