SQL query : count and result one query in MySQL Table: banks
bank_id | bank_name | bank_abbrev |
---|---|---|
1 | Bangkok | BBL |
2 | Kasikornthai | KBANK |
3 | Siam Commercial | SCB |
4 | Krungthai | KTB |
5 | Krungsri | BAY |
SELECT b.*, t.total FROM banks b LEFT JOIN ( SELECT count(*) AS total FROM banks ) AS t ON b.bank_id != -1 LIMIT 0, 3Query results:
bank_id | bank_name | bank_abbrev | total |
---|---|---|---|
1 | Bangkok | BBL | 5 |
2 | Kasikornthai | KBANK | 5 |
3 | Siam Commercial | SCB | 5 |
1 comments:
ผมลืมไปแล้ว sql เขียนยังไง
Post a Comment