我有一个表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吗? –