mysql - Looking for help on joining query -


im taking first programming (sql) class. i've got no tech background whatsoever , i'm having little trouble getting code down. here database looks like.

book

  book_code (unique)   booktitle   publisher_code   booktype   price 

inventory

 book_code (unique)  branch_num (unique)  on_hand 

the question is, list books (titles) available in branches 3 , 4 (on both @ same time).

im thinking need use following tables: booktitle on book table , bookcode on both tables ( book , inventory), , branch_num on inventory table.

also answer can show book titles available on branches 3 , 4 (at same time) , no other columns.

sorry if im making no sense. said im n00b.

select booktitle book book_code in (select book_code inventory branch_num = 3 , on_hand > 0)     , book_code in (select book_code inventory branch_num = 4 , on_hand > 0); 

or

select booktitle (     select book.book_code, booktitle, count(*) branch_count book     inner join inventory on book.book_code = inventory.book_code         , inventory.branch_num in (3, 4)     group book.book_code, booktitle ) b b.branch_count = 2; 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -