concatenate 2 columns in mysql code example

Example 1: mysql concatenate two columns into one

SELECT concat(first_column, ' ', second_column) from table_name

Example 2: mysql concat and use as where column

select * from table where concat_ws(' ',first_name,last_name) 
like '%$search_term%';

Example 3: how to join more then 2 column in mysql

SELECT
  s.last_name, s.first_name,
  p.course_code, p.status, p.amount
FROM enrollment e
JOIN student s
  ON s.id=e.student_id
JOIN payment p
  ON p.course_code=e.course_code
    AND p.student_id=e.student_id;

Tags:

Sql Example