0

I have an order table with the user_fk column and invoice column. Let's just say I want to get an order instance that is related to my user but with an empty invoice column. How do I do that with mysql?

perhaps this will illustrate it

"SELECT * FROM order WHERE user_fk = $user_fk AND invoice === false;"

edit: invoice column is an interger

Melly
  • 675
  • 8
  • 24

2 Answers2

1
SELECT * FROM order WHERE user_fk = $user_fk AND invoice is null or invoice = '';

Try this if invoice supports null

Mykyta Halchenko
  • 720
  • 1
  • 3
  • 21
0

You can check whether the invoice column is null or length of column is 0.

SELECT * FROM order WHERE user_fk = $user_fk AND (invoice is null or len(invoice)=0);