1

我有两张桌子

桌子login

account_id    |    name
========================
12345         |    thuong1
12346         |    thuong2
12347         |    thuong3

桌子char

account_id    |    char
========================
12345         |    name1
12345         |    name2
12345         |    name3
12345         |    name4

我要选择...

SQL 1

SELECT account_id FORM char WHERE char='name1'

我会有结果

12345

SQL 2

SELECT login.account_id, login.name, char.char WHERE login.account_id=char .account_id GROUP BY login.account_id , login.name, char.account_id, char.char HAVING login.account_id = 12345

结果

account_id | name    | char  
12345      | thuong1 | name1  
12345      | thuong1 | name2  
12345      | thuong1 | name3  

我如何用 1 个 sql 查询选择它?

4

1 回答 1

3
SELECT  a.account_ID,
        a.name, 
        b.char
FROM    login a
        INNER JOIN char b
            ON a.account_ID = b.account_ID
WHERE   a.name='thuong1'
于 2012-11-10T15:37:51.437 回答