国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

php - Mysql's left join query, when a field in the right table is empty, why can't the corresponding field in the left table be found?
高洛峰
高洛峰 2017-06-05 11:08:00
0
2
533
SELECT category.c_id,category.c_name,jobs.amount FROM qs_category as category 
LEFT JOIN qs_jobs as jobs ON category.c_id=jobs.trade 
WHERE jobs.addtime >= 1483200000 AND jobs.addtime <= 1498838400 

This is the query statement. The left table category is the classification table, and the right table jobs is the position table. I want to count the number of positions under each category.
But there is a problem with the result. If a certain category does not exist in the category field of the job table, that is to say, no one has added a position under this category, then this category will not be displayed in the query results.
But it stands to reason that if there is a left join, even if there is no corresponding data in the right table, the fields in the left table should still be displayed

高洛峰
高洛峰

擁有18年軟件開發(fā)和IT教學經(jīng)驗。曾任多家上市公司技術(shù)總監(jiān)、架構(gòu)師、項目經(jīng)理、高級軟件工程師等職務(wù)。 網(wǎng)絡(luò)人氣名人講師,...

reply all(2)
劉奇

Of course, the table on the right where you wrote the where condition cannot be found. When the right table is empty, the condition field is also empty, and it is filtered out by your where condition.

漂亮男人

I have also encountered this situation. It was filtered out by your where condition. The solution is to append the conditions written in where to on!
where is to filter the result set after connecting the tables, but if the condition in on is false, the data in the left table will be returned, and the right table will be empty

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template