1

私は2つのテーブルを持っています

テーブル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 に答える