Answers for "mysql search multiple tables"

SQL
0

mysql search multiple tables

SELECT
  users_first_name,
  users_last_name
FROM
  (
    (
      SELECT
        users.first_name AS users_first_name,
        users.last_name AS users_last_name
      FROM
        users
        INNER JOIN companies ON companies.id = users.company_id
      WHERE
        (
          users.last_name LIKE 'TERM%'
        )
    )
    UNION
      DISTINCT (
        SELECT
          users.first_name AS users_first_name,
          users.last_name AS users_last_name
        FROM
          users
          INNER JOIN companies ON companies.id = users.company_id
        WHERE
          (users.first_name LIKE 'TERM%')
      )
    UNION
      DISTINCT (
        SELECT
          users.first_name AS users_first_name,
          users.last_name AS users_last_name
        FROM
          users
          INNER JOIN companies ON companies.id = users.company_id
        WHERE
          (companies.name LIKE 'TERM%')
      )
  ) AS union1;
Posted by: Guest on October-27-2021

Code answers related to "mysql search multiple tables"

Code answers related to "SQL"

Browse Popular Code Answers by Language