Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

MYSQL Inner Join if pernyataan

Select user.userID
    , username
    , user.email
    , registeredBy, registeredDate
    , Case 
        When User.Level = 2 Then Concat(Level2Staff.firstName, ' ' , Level2Staff.lastName) 
        When User.Level = 1 Then Concat(customer.firstName, ' ' , customer.lastName) 
        End
        AS staffName 
FROM user
    Inner Join level
        On user.levelID = level.levelID 
    Inner Join staff
        On user.registeredBy = staff.UserID
    Left Join customer
        On customer.userID = user.UserID
            And user.level = 1
    Left Join staff As Level2Staff
        On user.userID = Level2Staff.UserID


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. SequelizeJS - hasMany to hasMany di tabel yang sama dengan tabel join

  2. Integrasi WordPress MediaWiki

  3. SQL Query mana yang membutuhkan lebih banyak waktu? (MYSQL)

  4. MYSQL - Cara mengatasi batas ukuran baris 66 KBytes

  5. Mengapa menggunakan InnoDB melalui MySIAM