title: MYSQL Query for combobox
body: <p>I have two  tables in my database.namely books and bookidofid. where bookidofid from books table is referenced to bookidofid from bookidofid table</p>
  
  <p>Table books                                                   </p>
  
  <pre><code>bookid bookname bookidofid                     
  0         A       0                            
  1         B       0                            
  2         C       1                            
  3         D       2                            
  4         E       3                            
  </code></pre>
  
  <p>Table bookidofid</p>
  
  <pre><code>bookidofid
  0
  1
  2
  3
  </code></pre>
  
  <p>but in UI, I have made bookidofid as combobox . In that combobox, I have added all booknames. I have got it . </p>
  
  <p>but When I edit E, I want A,B,C,D in the combobox. 
  I will explain this with example</p>
  
  <pre><code>        _ _ North America __USA___Washington_ XX
          |
          |
  America_|
          |
          |__ _ South America_Brazil__Rio di Janerio _YY
  </code></pre>
  
  <p>When I edit XX in bookname text box, I need America,North America ,USA, Washington in bookidofid combobox.
   When I edit YY in bookname text box, I need America,South America,Brazil, Rio di Janerio in bookidofid combobox. </p>
  
  <p>Based on this example, I need a mysql query. I have tried but I couldn't get the correct query for this problem. 
  I am doing this one in JAVA.</p>
  
  <p>EDIT: OP's Query</p>
  
  <pre><code>select bookname 
  from books b,
  bookidofid bo 
  from bookidofid 
  where b.bookidofid=bo.bookidofid; 
  </code></pre>
  
  <p>(it will return all book names in the combobox) </p>
  
  <p>FOR EDIT: </p>
  
  <pre><code>select bookname,bookid,bookidofid 
  from books b 
  where bookname NOT IN (select bookidofid from bookidofid bo) 
  </code></pre>