如何使用连接查询来合并订单,客户,类别和产品表?请回复
问题描述:
大家好
i想要使用加入查询
Hi everyone
i want to use join query
SELECT ord.orderid,cus.custid,cus.custname,cat.catid,cat.catname,pro.proid,pro.proname from 'order' as ord inner join 'customer' as cus on cus.custid=ord.custid innerjoin 'category' as cat on cat.catid=ord.catid innerjoin 'product' as pro on pro.proid=ord.orderid
我不知道它有什么问题
请帮助我紧急
[edit]已添加代码块,拼写[/ edit]
i don't know what's wrong with it
kindly help me outits urgent
[edit]Code block added, spelling[/edit]
答
innerjoin
应该是
shoud be
inner join
和
and
pro.proid = ord.orderid
应该是???
shoud it be ???
pro.proid = ord.proid
此外,你不能使用'order'作为表名,因为它是一个保留字MySQL的。但是你可以尝试使用反引号来将它包围起来,就像这些`order`一样,可以在101键盘的左上角找到反引号。对其他表格执行相同的操作。
In addition, you cannot use 'order' as table name as it is a reserved word in mysql. But you can try using backticks ` to enclose it like these `order`, the backtick can be found on the top left hand side of your 101 keyboard. Do the same for the other tables.