今天我尝试了一些更复杂的MySQL查询,我注意到MySQL的LEFT JOIN不能与WHERE子句一起使用.我的意思是,它确实会返回一些记录,但它不会返回右侧为空的记录.
例如,假设我们需要表格:
albums ; albums_rap id artist title tracks ; id artist title rank ---- -------- ---------- --------------- ; ---- --------- ----- -------------- 1 John Doe Mix CD 20 ; 3 Mark CD #7 15 2 Mark CD #7 35 ;
当我运行此查询时:
SELECT
t1.artist as artist,
t1.title as title,
t1.tracks as tracks,
t2.rank as rank,
FROM
albums as t1
LEFT JOIN
albums_rap as t2
ON
t1.artist LIKE t2.artist
AND
t1.title LIKE t2.title
WHERE
t2.rank != 17
Run Code Online (Sandbox Code Playgroud)
我明白了:
artist title …
我有注射从RabbitMQ的生产问题RabbitMqBundle到我的服务。
服务:
namespace App\Service;
use Carbon\Carbon;
use Doctrine\ORM\EntityManagerInterface;
use OldSound\RabbitMqBundle\RabbitMq\ProducerInterface;
class RatingPositionRecalculateService
{
protected $entityManager;
protected $positionProducer;
public function __construct(EntityManagerInterface $entityManager, ProducerInterface $producer)
{
$this->entityManager = $entityManager;
$this->positionProducer = $producer;
}
public function recalculate(Carbon $day)
{
// do stuff
}
}
Run Code Online (Sandbox Code Playgroud)
old_sound_rabbit_mq.yml:
old_sound_rabbit_mq:
connections:
default:
url: ''
producers:
rating_position:
connection: default
exchange_options: { name: 'rating_position', type: direct }
consumers:
rating_position:
connection: default
exchange_options: {name: 'rating_position', type: direct}
queue_options: {name: 'rating_position'}
callback: rating_position_service
Run Code Online (Sandbox Code Playgroud)
我得到:
Cannot autowire service "App\Service\RatingPositionRecalculateService": argument …Run Code Online (Sandbox Code Playgroud)