How to use INNER JOIN?
What is ‘select_related’ in Django Queries?
---------------------------------------------------------------------------
SELECT `products`.`productCode`, `products`.`productName`, `products`.`productLine`, `products`.`productScale`,
`products`.`productVendor`, `products`.`productDescription`, `products`.`quantityInStock`, `products`.`buyPrice`, `products`.`MSRP`,
`productlines`.`productLine`, `productlines`.`textDescription`, `productlines`.`htmlDescription`, `productlines`.`image`
FROM `products`
INNER JOIN `productlines` ON (`products`.`productLine` = `productlines`.`productLine`)
data = Products.objects.select_related('productline')
SELECT `products`.`productCode`, `products`.`productName`, `products`.`productLine` FROM `products`
INNER JOIN `productlines` ON (`products`.`productLine` = `productlines`.`productLine`)
WHERE `productlines`.`textDescription`
LIKE Attention%
data = Products.objects.filter(productline__textdescription__istartswith='Attention').values_list('productcode', 'productname', 'productline')
SELECT `products`.`productCode`, `products`.`productName`, `products`.`productLine`, `products`.`productScale`,
`products`.`productVendor`, `products`.`productDescription`, `products`.`quantityInStock`, `products`.`buyPrice`, `products`.`MSRP`
FROM `products`
INNER JOIN `productlines` ON (`products`.`productLine` = `productlines`.`productLine`)
WHERE `productlines`.`textDescription` LIKE Attention%
data = Products.objects.filter(productline__textdescription__istartswith='Attention')
![](https://s2.save4k.ru/pic/qPSFMmrhgnY/maxresdefault.jpg)