如何通过 concat select 有条件的行?
How to select rows with condition via concat?
SELECT CONCAT_WS(' ',NAME, SURNAME, 'was born in', DATE_FORMAT(BIRTHDAY,'%Y')) AS RESULT
FROM STUDENT
WHERE KURS == 1 OR KURS == 2;
我只需要 KURS 列包含“1”或“2”的那些行
SELECTS * FROM STUDENTS
MySQL 中没有 ==
运算符。大概,你的意思是:
WHERE KURS = 1 OR KURS = 2
可以简化为:
WHERE KURS IN (1, 2)
SELECT
子句看起来不错,应该可以正常工作。
像这样创建子 select 可能有效:
SELECT * FROM
(SELECT CONCAT_WS(' ',NAME, SURNAME, 'was born in', DATE_FORMAT(BIRTHDAY,'%Y')) AS RESULT
FROM STUDENT
WHERE KURS == 1 OR KURS == 2) AS Query
WHERE KURS = 1
SELECT CONCAT_WS(' ',NAME, SURNAME, 'was born in', DATE_FORMAT(BIRTHDAY,'%Y')) AS RESULT
FROM STUDENT
WHERE KURS == 1 OR KURS == 2;
我只需要 KURS 列包含“1”或“2”的那些行
SELECTS * FROM STUDENTS
MySQL 中没有 ==
运算符。大概,你的意思是:
WHERE KURS = 1 OR KURS = 2
可以简化为:
WHERE KURS IN (1, 2)
SELECT
子句看起来不错,应该可以正常工作。
像这样创建子 select 可能有效:
SELECT * FROM
(SELECT CONCAT_WS(' ',NAME, SURNAME, 'was born in', DATE_FORMAT(BIRTHDAY,'%Y')) AS RESULT
FROM STUDENT
WHERE KURS == 1 OR KURS == 2) AS Query
WHERE KURS = 1