English 中文(简体)
离开外部加入询问(我认为)
原标题:Left outer join query (i think)

我有两张这样的表格:

产品:id>>。

出售品编号:E.06.XI.1。

<编码>产品_id是产品中的一项外国关键产品id 表格

我写了JOIN的准备声明,如:

SELECT p.name, p.description, s.link FROM products AS p
INNER JOIN sales_sheets AS s ON p.id = s.product_id WHERE active=1 AND category=?

基本上,产品可以与人民国防军有联系,但并非所有产品都将有销售单。 因此,如果试图生产一只产品,而该产品有一张附着的销售单,它就永远不会有收益。

因此,我认为,我不得不使用LEFT OUTER JOIN取代INNER JOIN,但是,如果我把表格命名为错误的顺序,那就不会有增长? 我从未像以前一样使用过一种词汇?

最佳回答
SELECT p.name, p.description, s.link FROM products p
LEFT JOIN sales_sheets s ON p.id = s.product_id
WHERE active = 1 && category = ?
问题回答

暂无回答




相关问题
trrying to optimize the query

I am just trying to left join and attach all the table but remaining table seems to be same is there any other way to attach the table like function or temp table to optimize it. SELECT Business ...

Slow query - Multiple joins and a lot of data

I m sure there is a better way I could be doing this. I have three main tables with large amounts of data to run through: records_main, sales, and appointments. Each with close to 20,000 records. I ...

Is an outer join possible with Linq to Entity Framework

There are many examples of outer join using Linq to Sql, all of them hinging on DefaultIfEmpty() which is not supported with Linq to Entity Framework. Does this mean that outer join is not possible ...

MYSQL DATE function running insanely slow in LEFT JOIN

When adding the line: LEFT JOIN core_records_sales as sales ON DATE(appointments.date) = DATE(sales.date_sold) To my query, it boosts the time for the script to run from about 8 seconds, to 2-3 ...

Limiting Access by Permission

thanks for viewing this. I have a db that has users, roles & user_roles. What I am trying to achieve is a login that will select users who have Admin or Associate permissions. The login then uses ...

热门标签