从多个表中选择而不使用join和union

时间:2016-06-30 16:37:40

标签: mysql sql join union

我有以下SQL查询:

SELECT t1.id as id,
       t1.username as username,
       CONCAT_WS(' ', t2.ad,t2.soyad) as fullname,
       t2.title as title,
       t3.pass as password,
       t3.phone_login as hat,
       t2.time as date
FROM kullanici t1, kullanici_tanim t2, dial_users t3
WHERE t1.id = t2.usr_id AND t1.agent_id = t3.user_id
GROUP  BY  t1.id
ORDER BY t1.id ASC

此查询正常。我想知道的是我应该使用连接吗?什么是正确的方法?

1 个答案:

答案 0 :(得分:0)

对于ANSI-92-compliant code使用联接。 E.g:

SELECT   t1.id as id,
             t1.username as username,
             CONCAT_WS(' ', t2.ad,t2.soyad) as fullname,
             t2.title as title,
             t3.pass as password,
             t3.phone_login as hat,
             t2.time as date
FROM kullanici t1 
     INNER JOIN kullanici_tanim t2 
     ON t1.id = t2.usr_id 
     INNER JOIN dial_users t3
     ON t1.agent_id = t3.user_id
GROUP  BY  t1.id
ORDER BY t1.id ASC