I'm creating simple app, which will be able to read data from database and show it to user.
I know basic syntax for MySQL and I know how to write it properly, but maybe there is some different / more pretty solution?
When you searching through database you don't have to fill all fields (e.g. you want to find persons only with name "John", so you leave field "surname" empty).
I need to create MySQL statement without using empty fields, so I thought using short if, something like that:
"SELECT * FROM offers WHERE ".($Company_Name!= NULL)?"":"Company_Name ='".$Company_Name."'"
But I have 8 fields, so I would make really big statement for that. Is there any shorter / easier way to solve it?
I'm using NetBeans 8.2 on Windows 10, and XAMPP for Apache server and Database.