Can I use the result of a select statement from mysql to compare it with a variable? -


i have following code in stored procedure:

set cont_email = select email contacts  id=in_id;  if in_customer_email = cust_email  **do something** 

so, wondering if instead of creating local variable , storing result select statement paste directly in if statement so:

if in_customer_email = (select email contacts  id=in_id)      **do something** 

also, wondering how can use ors in mysql.

can this?

if in_customer_email = customer_email or in_customer_name = customer_name 

i have seen use of or this:

select customer_id, customer_name customers (customer_name = 'apple' or customer_name = 'samsung') 

but never inside of if statement, wasn't sure.

and lastly, has been ages since use if var1 = var2, since used assigning not compare, wondering if correct or have use double equal sign var1 == var2.

thanks.

variable vs. nested statement?

if in_customer_email = (select email contacts  id=in_id)  **do something** 

this legal query -- no need declare variable beforehand.

ors in if statements?

if in_customer_email = customer_email or in_customer_name = customer_name 

this legal (and quite useful).

use = or == compare values?

if var1 = var2 

this is, contrary programmer spidey-sense may indicate, proper way compare values in mysql queries.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -