Search
 
SCRIPT & CODE EXAMPLE
 

SQL

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;
Comment

select multiple tables mysql

SELECT t1.dt2, t2.dt4, t2.dt5, t2.dt3 #get dt3 data from table2
FROM table1 t1, table2 t2 -- Doesn't need to have t1, or t2
WHERE t1.dt2 = 'asd' AND t2.dt4 = 'qax' AND t2.dt5 = 456
Comment

PREVIOUS NEXT
Code Example
Sql :: how to find sql server installation folder 
Sql :: sql update multiple tables 
Sql :: first mysql 
Sql :: not operator in sql 
Sql :: operator in sql 
Sql :: demmarrer un service mysql teminal cmd 
Sql :: set engine to innodb 
Sql :: devilbox mysqldump 
Sql :: how to select from mssql 
Sql :: mdl ddl acl 
Sql :: find most frequent word in sql server 
Sql :: how to delete python anywhere mysql database 
Sql :: how to replace null values in sql 
Sql :: alter in sql 
Sql :: sql server whoami 
Sql :: MySql Subtract a table from another 
Sql :: create directory in sql server 
Sql :: oracle merge insert if not exists 
Sql :: index postgres 
Sql :: linux upload database to mysql 
Sql :: oracle sql trigger select into 
Sql :: postgres trim string 
Sql :: oracle job schedules 
Sql :: T-SQL and the WHERE LIKE %Parameter% clause 
Sql :: mysql regex select 
Sql :: get last inserted primary key 
Sql :: find max number in sql 
Sql :: sql date before 
Sql :: drop constraint in ms sql 
Sql :: sorting desc in sql 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =