Home sql Sampling from multiple tables inner join

Sampling from multiple tables inner join

Author

Date

Category

There is a structure of the following type of database:
Enter the image description here

I need to make a sample from the DRIVERS table (Date, Pack, Directory) and USABLE (SYSTEM). When writing a request, I (most likely) somewhere decartularly a work, for a large number of rows are issued – duplicates. Using the Distinct problem decides, removing duplicates, and I get the desired result, but I myself understand that this is terrible crutches and do not need to do so. Below is the text of my request, see, maybe I do an obvious error:

select drivers.pack drivers.directory, drivers. [Date], USABLE. [SYSTEM]
From Sections Inner Join Drivers
ON.
(
  Drivers.id in
  (
    SELECT DRIVERID From Sections Where Sections.id in
    (
      SELECT SECTIONID FROM USABLE WHERE DEVICEID IN
      (
        SELECT ID FROM DEVICES WHERE DEVICEID LIKE "% VEN_14F1%" AND DEVICEID LIKE "% dev_8880%"
      )
    )
  )
  and drivers.id = sections.driverid
)
Inner Join usable
ON.
(
   USABLE. [SYSTEM] = "6.1X64"
   And.
   USABLE.SECTIONID = sections.id.
)
ORDER BY (Drivers. [Date]) DESC;

Tell me the decision.
P.S.: The code formatted, I hope so it will be more convenient to read.

UPD:

select
  DRIVERS.DATE,
  Drivers.pack,
  DRIVERS.DIRECTORY,
  Usable.system
From.
  Drivers.
Inner Join Sections On Drivers.id = sections.driverid
Inner Join USable On Sections.ID = USABLE.SECTIONID
Inner Join Devices ON USABLE.DEVICEID = Devices.id
Where Devices.DeviceID Like "% Ven_14F1%" and devices.DeviceID Like "% dev_8880%" and usable.system = '6.1x64'
ORDER BY (Drivers. [Date]) DESC;

Answer 1, Authority 100%

Try:

select
  DRIVERS.DATE,
  Drivers.pack,
  DRIVERS.DIRECTORY,
  Usable.system
From.
  Drivers.
Inner Join Sections On Drivers.id = sections.driverid
Inner Join USable On Sections.ID = USABLE.SECTIONID
Whater
  USABLE.DEVICEID LIKE "% VEN_14F1%" AND USABLE.DEVICEID LIKE "% dev_8880%" and usable.system = '6.1x64'

Answer 2

Using the grouping solves the problem:

group by (drivers.directory)

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions