Προς το περιεχόμενο

Προτεινόμενες αναρτήσεις

Δημοσ.

Καλησπέρα,

παίζω με ένα query

SELECT maker FROM product LEFT JOIN PC ON product.model=PC.model WHERE maker NOT IN (product LEFT JOIN Laptop ON product.model=Laptop.model)

Incorrect syntax near the keyword 'LEFT'.

 

κια παιρνω αυτό το λάθος. Γιατί?

Δημοσ.

μεσα στην παρενθεση πρεπει να μπει select:

SELECT maker FROM product LEFT JOIN PC ON product.model=PC.model WHERE maker NOT IN (SELECT maker FROM product LEFT JOIN Laptop ON product.model=Laptop.model)
Δημοσ.

καλημερα,

βαζω την περιγραφη

 

Product(maker, model, type)
PC(code, model, speed, ram, hd, cd, price)
Laptop(code, model, speed, ram, hd, screen, price)
Printer(code, model, color, type, price)
The table "Product" includes information about the maker, model number, and type ('PC', 'Laptop', or 'Printer'). It is assumed that model numbers in the Product table are unique for all the makers and product types. Each PC uniquely specifying by a code in the table "PC" is characterized by model (foreign key referencing to Product table), speed (of the processor in MHz), total amount of RAM - ram (in Mb), hard disk drive capacity - hd (in Gb), CD ROM speed - cd (for example, '4x'), and the price. The table "Laptop" is similar to that one of PCs except for the CD ROM speed, which is replaced by the screen size - screen (in inches). For each printer in the table "Printer" it is told whether the printer is color or not (color attribute is 'y' for color printers; otherwise it is 'n'), printer type (laser, jet, or matrix), and the price.

 

Find out the makers that sale PCs but not laptops.

Δημοσ.

Γιατί κάνεις JOIN στους άλλους πίνακες; Η πληροφορία που χρειάζεσαι περιέχεται ολόκληρη στον πίνακα product.

select distinct maker from product
where `type` = 'pc' and maker not in (select distinct maker from product where `type` = 'laptop')

"Δείξε μου όλους τους maker που πουλάνε PC εκτός από αυτούς που πουλάνε laptop".

Δημοσ.

Γιατί κάνεις JOIN στους άλλους πίνακες; Η πληροφορία που χρειάζεσαι περιέχεται ολόκληρη στον πίνακα product.

select distinct maker from product
where `type` = 'pc' and maker not in (select distinct maker from product where `type` = 'laptop')

"Δείξε μου όλους τους maker που πουλάνε PC εκτός από αυτούς που πουλάνε laptop".

 

Πολυ σωστος defacer. Δε μου περασε απο το μυαλο!

Δημοσ.

Αυτό περισσεύει:  and maker not in (select distinct maker from product where `type` = 'laptop')

select distinct maker from product where type = 'pc'

 

εκτός αν δε θες καθόλου αυτούς που πουλάνε laptop

Δημοσ.

 

Αυτό περισσεύει:  and maker not in (select distinct maker from product where `type` = 'laptop')

select distinct maker from product where type = 'pc'

καλημερα,

βαζω την περιγραφη

 

Find out the makers that sale PCs but not laptops.

Δημοσ.

 

Αυτό περισσεύει:  and maker not in (select distinct maker from product where `type` = 'laptop')

select distinct maker from product where type = 'pc'

καλημερα,

βαζω την περιγραφη

 

Find out the makers that sale PCs but not laptops.

 

 

Δεν ειχα δει περιγραφή, γι'αυτο έγραψα "εκτός αν δε θες καθόλου αυτούς που πουλάνε laptop" :)

Δημιουργήστε ένα λογαριασμό ή συνδεθείτε για να σχολιάσετε

Πρέπει να είστε μέλος για να αφήσετε σχόλιο

Δημιουργία λογαριασμού

Εγγραφείτε με νέο λογαριασμό στην κοινότητα μας. Είναι πανεύκολο!

Δημιουργία νέου λογαριασμού

Σύνδεση

Έχετε ήδη λογαριασμό; Συνδεθείτε εδώ.

Συνδεθείτε τώρα
  • Δημιουργία νέου...