Anubis13 Δημοσ. 28 Νοεμβρίου 2013 Δημοσ. 28 Νοεμβρίου 2013 Καλησπέρα, παίζω με ένα 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'. κια παιρνω αυτό το λάθος. Γιατί?
Mika Δημοσ. 28 Νοεμβρίου 2013 Δημοσ. 28 Νοεμβρίου 2013 μεσα στην παρενθεση πρεπει να μπει 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)
Anubis13 Δημοσ. 29 Νοεμβρίου 2013 Μέλος Δημοσ. 29 Νοεμβρίου 2013 Σε αυτη την ασκηση μπορει να μου εξηγησει καποιος γιατι το LEFT Join δινει κενο αποτελεσμα ενω το INNER JOIN δινει το σωστο http://www.sql-ex.ru/learn_exercises.php?LN=8
Mika Δημοσ. 29 Νοεμβρίου 2013 Δημοσ. 29 Νοεμβρίου 2013 χρειαζεται credentials για να δεις την ασκηση.
Anubis13 Δημοσ. 29 Νοεμβρίου 2013 Μέλος Δημοσ. 29 Νοεμβρίου 2013 καλημερα, βαζω την περιγραφη 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.
djcat Δημοσ. 29 Νοεμβρίου 2013 Δημοσ. 29 Νοεμβρίου 2013 Δεν είδα την άσκηση. Αλλά νομίζω με το σχήμα θα καταλάβεις τι παίζει. http://stackoverflow.com/questions/5706437/whats-the-difference-between-inner-join-left-join-right-join-and-full-join
defacer Δημοσ. 29 Νοεμβρίου 2013 Δημοσ. 29 Νοεμβρίου 2013 Γιατί κάνεις 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".
Anubis13 Δημοσ. 29 Νοεμβρίου 2013 Μέλος Δημοσ. 29 Νοεμβρίου 2013 Γιατί κάνεις 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. Δε μου περασε απο το μυαλο!
Stamer Δημοσ. 29 Νοεμβρίου 2013 Δημοσ. 29 Νοεμβρίου 2013 Αυτό περισσεύει: and maker not in (select distinct maker from product where `type` = 'laptop') select distinct maker from product where type = 'pc' εκτός αν δε θες καθόλου αυτούς που πουλάνε laptop
defacer Δημοσ. 29 Νοεμβρίου 2013 Δημοσ. 29 Νοεμβρίου 2013 Αυτό περισσεύει: 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.
Stamer Δημοσ. 29 Νοεμβρίου 2013 Δημοσ. 29 Νοεμβρίου 2013 Αυτό περισσεύει: 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"
Προτεινόμενες αναρτήσεις
Δημιουργήστε ένα λογαριασμό ή συνδεθείτε για να σχολιάσετε
Πρέπει να είστε μέλος για να αφήσετε σχόλιο
Δημιουργία λογαριασμού
Εγγραφείτε με νέο λογαριασμό στην κοινότητα μας. Είναι πανεύκολο!
Δημιουργία νέου λογαριασμούΣύνδεση
Έχετε ήδη λογαριασμό; Συνδεθείτε εδώ.
Συνδεθείτε τώρα