Theme
Primary Color
Lesson 26

String Functions – Concat, Concat_Ws

الأوامر التي تم كتابتها في الدرس

/*
  Concat => CONCAT(String, String, String)
  text => Field Name
*/

SELECT id, text, CONCAT(text, ' Added By Me') AS mytext FROM `try`;

SELECT id, text, CONCAT('First ', text, ' Last') AS mytext FROM `try`;

SELECT
  id, text, CONCAT('This Country Is ', text, ' And Its ID Is ', id)
AS
  mytextwithid
FROM
  `try`;

/*
  Concat => CONCAT_WS(Separator, String, String)
  text => Field Name
*/

SELECT id, text, CONCAT_WS(',', text, ' Added') AS mytextwithid FROM `try`;

SELECT id, text, CONCAT_WS('-', text, ' Added') AS mytextwithid FROM `try`;

SELECT id, text, CONCAT_WS('-', text) AS mytextwithid FROM `try`;

SELECT id, text, CONCAT_WS(',', id, text) AS mytextwithid FROM `try`;

SELECT id, text, CONCAT_WS(',', id, ' ', text) AS mytextwithid FROM `try`;

SELECT id, text, CONCAT_WS(',', CONCAT(id, ' '), text) AS mytextwithid FROM `try`;

SELECT id, text, CONCAT_WS(',', CONCAT(id, ' '), CONCAT(' ', text)) AS mytextwithid FROM `try`;

SELECT id, text, CONCAT_WS(',', id, REPEAT(text, 2)) AS mytextwithid FROM `try`;

SELECT id, text, CONCAT_WS(',', id, REPEAT(text, 2)) AS mytextwithid FROM `try`;

SELECT id, text, REVERSE(CONCAT(id, text)) AS mytextwithid FROM `try`;

SELECT id, text, REVERSE(CONCAT(id, text, 'Osama')) AS mytextwithid FROM `try`;