mysql - How to avoid conditional multiple SELECT in a query -


i select this simple sql

  (case is when (select name customers where customers_id Customer = Customer) is not Zero (name Select from Customers where Customers_id = Customer) and Customer End) as Customer, DateStart, ProgramsRun.Programs_id, RunInSeconds, SwSQL, SwProgram, Name Programs Run Run ProgramName from left ProgramsRun.Programs_id = joining program programs .Programs_id;   

My question is how can I make two similar selection statements: in the form of a condition and the other as the price selection. I know that I can make a temporary variable, but it forces me to use stored procedures or temporary tables, is there an easy way to avoid this?

You can use it as IFNULL :

  IFNULL ((Where customers name customers_id = customer, select customer)   

or COALESCE like this:

Reference:



Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -