What's the proper way of creating a MySQL table for ` field (value is 0), what then will be the value of the table which uses this as a foreign key? I'm guessing `NULL` but doesn't NULL equate to `0` if the column is set to INT? – enchance Nov 24 '11 at 14:18

  • You could just ignore the "part" in your queries if the user decides to not use your select. What back-end language are you using? In PHP it would be like: `if($_POST['select'] == 0) // do nothing/alternative query` – Benedikt Wölk Nov 24 '11 at 14:20
  • Yup, PHP. If I evade it with a conditional, what of the foreign key then? Set it to `NULL`? – enchance Nov 24 '11 at 14:26
  • I don't know what you are going to achieve. Why are you using `INNER JOIN`? Use `LEFT JOIN` or `RIGHT JOIN` and MySQL will populate the field with NULL for you. – Benedikt Wölk Nov 24 '11 at 14:30
  • That's true. I guess I'll stick with inserting a `0` then since a blank value gets translated to 0 anyway: ``. – enchance Nov 24 '11 at 14:50
  • Be careful, if you do `INSERT INTO` and use 0 as value for the auto_increment coloum MySQL will create a new ID for you. – Benedikt Wölk Nov 24 '11 at 15:02
  • That's ok. The `0` will be for the foreign key while the primary key will be left at auto_increment (not 0). – enchance Nov 24 '11 at 15:11