Answer the question
In order to leave comments, you need to log in
How to make a query with join tables?
Hello. Passed the SQL course, faced the following task:
database.db3 ( https://drive.google.com/file/d/10Q9DHIiBMRJgGx17I... )
docs - Documents
id - Document identifier (its number)
date - Document creation date
typeId - Document type (docTypes.id)
removed - Indicates that the document has been removed
rows - Document lines
id - Document line identifier
docId - Document identifier to which the line belongs (docs.id)
productId - Product identifier (products.id)
quantity - Product quantity
removed - A sign that the line has been removed
docTypes - Document types
id - Document type identifier
name - Document name
removed - Sign that this type of document is not used
products - Products
id - Goods identifier
name - Goods name
image - Goods image URL
price - Goods cost in rubles
removed - Goods available on sale
It is necessary to select all the data of not deleted and used documents (date of creation, document type, its number and lines of the document: product name, its image, price, quantity, availability on sale). The lines must follow the order in which the documents were created.
So the view should look like this:
2017-04-03 13:11:06 | Приход | 564564867361362 | ссылка | Аленка карамель 100г | 73.9 | 12 | 0
Answer the question
In order to leave comments, you need to log in
I will reveal one secret) all sql queries just reflect the condition of the problem! Therefore, everything that you wrote in the condition is a sql query * You just need to replace Russian words with language operators and rearrange where necessary ... You
need to select all the data of documents that are not deleted and used.
You need to SELECT * WHERE NOT docs.removed AND NOT docTypes.removed
now it remains only to add the FROM table ; where the data will be selected from, if there are several tables, link them according to the link condition;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question