我有一個表TBLCUTOMERS具有以下字段:如何在MYSQL查詢中添加子查詢?
- cutomerid
- customername
- customerphone
我有以下字段另一個表TBLTRANSACTIONS:
- transactionid
- customerid (foreign key to table above)
- transactiondetail
- transactionamount
我有一個查詢從tbltransactions獲得所有交易:
"select * from tbltransactions";
我怎樣才能在其中的子查詢,使得我的客戶名從TBLCUSTOMERS對上述查詢中的每個CUSTMERID?
期待輸出:
- transactionid
- customername (from tblcustomers)
- transactiondetail
- transactionamount
請注意,我是新來的MySQL。謝謝
您可以使用連接查詢將這項工作?我的意思是,如果我給你一個連接查詢不是子查詢會好嗎? –
當然!我只對結果感興趣。 –
你允許我們使用JOIN嗎? –