简体   繁体   中英

How to join two tables by 5 columns? Sql

I have two tables called customers and wantslist. I want to join the columns customername, customeraddress , creditlimit , bytitle and byauthor.

How can I write a query that can show those column together in a table?

The first table is customers. It has the columns customeraddress , customername and creditlimit.

The second table is wantslist. It has the columns bytitle and byauthor.

How can I write a query that can join those 5 columns into 1 table?

Without knowing your specific strucutre you would use a SQL query similar to...

SELECT c.customername, c.customeraddress, c.creditlimit, w.bytitle, w. byauthor
FROM customers as c
JOIN wantslist as w on c.customerid = w.customerid
SELECT customers.customername, customers.customeraddress, customer.creditlimit, wantslist.bytitle, wantslist.byauthor FROM wantslist INNER JOIN customers ON *{your matching condition}*;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM